superbigio
03-01-2003, 04:43 PM
How could I make the heapsort algorithm (chapter 8.3, page 337) work for an array [0...n-1] instead of an array[1...n] ?
Waiting for enlightment.
Thank you.
- Luigi Castelli
Saul Teukolsky
03-02-2003, 08:18 AM
Hi Luigi,
If all you want to do is call the routine with a vector with indices 0..n-1, take a look at pp. 18-19. If you want to actually translate the routine, it's not hard if you're careful with the indices. One place this is done is in the C++ version of the routine. Unfortunately this is not available online.
Hope this helps.
Saul Teukolsky