0

I need to no do we have a way to apply max-heapify algorithm?do we have to apply it from bottom to top or top to bottom?or can we apply to the places that heap property is not there? when we are going to maintain the heap property in a tree.

Pseudo code is given below

can any body help?

Sanjaya
  • 156
  • 1
  • 9

1 Answers1

0

I am not able to get your question absolutely But I think your doubt is whether we are moving from top to bottom or from bottom to top.
Actually in the heapify we move from top node(i) to the bottom(leaf nodes), and try to maintain the heap property as we move.
A: an array where the left and right children of i root heaps, i: an array index
have a look at this resource. http://homepages.ius.edu/RWISMAN/C455/html/notes/Chapter6/heapify.htm
see this pdf for more details.
http://courses.csail.mit.edu/6.006/fall10/handouts/recitation10-8.pdf

hope this clears your doubt.

govindpatel
  • 2,539
  • 2
  • 19
  • 20
  • you have understand the question correctly..I need to know weather that algorithm only deals with the 3 elements(Root,left and right childs)when we apply it one time?or it will deal with the whole tree? – Sanjaya Oct 11 '14 at 05:15