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
The below figure illustrates the BOM (Bill of Materials) for product A. The MPS (Material requirements Planning) start row in the master production schedule for product A calls for

need an expert to help me with the assignment

Ans. An algorithm for the quick sort is as follows: void quicksort ( int a[ ], int lower, int upper ) { int i ; if ( upper > lower ) { i = split ( a, lower, up

With the help of a program and a numerical example explain the Depth First Traversal of a tree.

Merging 4 sorted files having 50, 10, 25 and 15 records will take time

The fundamental element of linked list is a "record" structure of at least two fields. The object which holds the data & refers to the next element into the list is called a node .

Suppose there are exactly five packet switches (Figure 4) between a sending host and a receiving host connected by a virtual circuit line (shown as dotted line in figure 4). The tr

There are four data type groups:  Integer kepts whole numbers and signed numbers Floating-point Stores real numbers (fractional values). Perfect for storing bank deposit

How to create an General Tree and how to search general tree?

What do you mean by complexity of an algorithm? The complexity of an algorithm M is the function f(n) which gives the running time and/or storage space need of the algorithm i