11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

244 Chap. 7 Internal Sortingof size n − 1. Removing the new maximum (root) value places the second largestvalue in position n − 2 of the array. After removing each of the remaining values inturn, the array will be properly sorted from least to gre<strong>at</strong>est. This is why Heapsortuses a max-heap r<strong>at</strong>her than a min-heap as might have been expected. Figure 7.15illustr<strong>at</strong>es Heapsort. The complete Java implement<strong>at</strong>ion is as follows:st<strong>at</strong>ic

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!