Solved

Trivial Build Max Heap Question

Posted on 2004-10-04
3
373 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

627 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