Trivial Build Max Heap Question

Hello,

I was trying to remember the max heap, and I came up with this pseudocode.  However, I forget why the loop index i (2nd line) decreases from floor of length[A]/2 to 1 rather than increase from 1 to floor of length[A]/2.

-----------------------------------------------------
pseudocode:
-----------------------------------------------------
BuildMaxHeap(A)
1    heapSize[A] <-- length[A]
2    for i <-- length[A]/2 down to 1
3        do MaxHeapify(A,i)
-----------------------------------------------------

Thank you!

-luna621 =^^=
luna621Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
luna621Author Commented:
Once again zzynx, you have out done yourself.  That website was very helpful.  I'll study it to refresh my heaps :D
0
 
zzynxSoftware engineerCommented:
:°) Thanks
0
All Courses

From novice to tech pro — start learning today.