Heap

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Binary heap

A Binary Heap is a Binary Tree with following properties: 1) It's a complete tree. This property of Binary Heap makes them suitable to be stored in an array. 2) A Binary Heap is either Min Heap or Max Heap.

What is a Heap?

A heap is a binary tree storing keys at its nodes and satisfying the following properties: Heap-Order; Complete Binary Tree.

Height of a Heap

A heap storing n keys has height O(log n)

Downheap time complexity

Since a heap has height O(log n), downheap runs in O(log n) time.

Heap-Order

for every internal node v other than the root, key(v) >= key(parent(v)) The last node of a heap is the rightmost node of maximum depth

Algorithm upheap

restores the heap-order property by swapping k along an upward path from the insertion node. Upheap terminates when the key k reaches the root or a node whose parent has a key smaller than or equal to k . Since a heap has height O(log n), upheap runs in O(log n) time.


संबंधित स्टडी सेट्स

Chapter 2 - Final Exam - MIE 330

View Set

intro to Communication: Exam Q&As

View Set

Environmental Science Chapter 10

View Set

Ch. 25: Emergency Management and Preparedness

View Set