Thread: Heap Sorting
View Single Post
  #2 (permalink)  
Old 11-13-2007, 05:04 PM
ShoeNinja's Avatar
ShoeNinja ShoeNinja is offline
Senior Member
 
Join Date: Oct 2007
Posts: 124
Rep Power: 0
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
Default
On the first iteration of the for loop, i=1 and j=3. During the while loop, j is incremented. At the end of the while loop, i=j (which is now 4) and j becomes 2*i+1 (9). In the second while loop, the statement array[i]=array[j] causes the exception because j is 9. I could be wrong though.
Reply With Quote