Solved

Trivial Build Max Heap Question

Posted on 2004-10-04
3
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

729 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