Representation of max-heap sequentially, Data Structure & Algorithms

Q. How do we represent a max-heap sequentially? Explain by taking a valid   example.        

Ans:

A max heap is also called as a descending heap, of size n is an almost complete binary tree of n nodes such as the content of each node is less than or equal to the content or matter of its father. If sequential representation of an almost whole binary tree is used, this condition reduces to the condition of inequality.

Info[j] <= info[(j-1)/2] for 0 <= ((j-1)/2) < j <= n-1

It is very much clear from this definition that root of the tree contains the largest element in the heap in the descending heap. Any of the paths from the root to a leaf is an ordered list in the descending order.


 

 

 

 

Posted Date: 7/10/2012 6:22:58 AM | Location : United States







Related Discussions:- Representation of max-heap sequentially, Assignment Help, Ask Question on Representation of max-heap sequentially, Get Answer, Expert's Help, Representation of max-heap sequentially Discussions

Write discussion on Representation of max-heap sequentially
Your posts are moderated
Related Questions
#2 example of recursion

Determine about the Post conditions assertion A  post condition is an assertion which should be true at completion of an operation. For instance, a post condition of the squ

Explain in detail about the Ruby arrays Ruby arrays have many interesting and powerful methods. Besides indexing operations which go well beyond those discussed above, arrays h

Q. Sort the sequence written below of keys using merge sort. 66, 77, 11, 88, 99, 22, 33, 44, 55                                                                      Ans:

insertion and deletion in a tree


In this sorting algorithm, multiple swapping occurs in one pass. Smaller elements move or 'bubble' up to the top of the list, so the name given to the algorithm. In this method,

Q1. Define a sparse matrix. Explain different types of sparse matrices? Evaluate the method to calculate address of any element a jk of a matrix stored in memory. Q2. A linear

Inorder traversal: The left sub tree is visited, then the node and then right sub-tree. Algorithm for inorder traversal is following: traverse left sub-tree visit node

Merging two sequence using CREW merge