Solved

Trivial Build Max Heap Question

Posted on 2004-10-04
3
330 Views
Last Modified: 2010-03-31
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 =^^=
0
Comment
Question by:luna621
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 100 total points
ID: 12224209
0
 

Author Comment

by:luna621
ID: 12224217
Once again zzynx, you have out done yourself.  That website was very helpful.  I'll study it to refresh my heaps :D
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12224235
:°) Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now