09.09.2014 Views

algorithms

algorithms

algorithms

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.

Figure 4.11 (a) A binary heap with 10 elements. Only the key values are shown. (b)–(d) The<br />

intermediate “bubble-up” steps in inserting an element with key 7. (e)–(g) The “sift-down”<br />

steps in a delete-min operation.<br />

(a) 3<br />

(b) 3<br />

10<br />

5<br />

10<br />

5<br />

11 12 6 8<br />

11 12 6 8<br />

15 20 13<br />

15 20 13 7<br />

(c) 3<br />

(d) 3<br />

10<br />

5<br />

7<br />

5<br />

11 7 6 8<br />

11 10 6 8<br />

15 20 13 12<br />

15 20 13 12<br />

(e)<br />

(f)<br />

12<br />

7<br />

5<br />

7<br />

5<br />

11 10 6 8<br />

11 10 6 8<br />

15 20 13 12<br />

15 20 13<br />

(g)<br />

5<br />

(h)<br />

5<br />

7<br />

12<br />

7<br />

6<br />

11 10 6 8<br />

11 10 12 8<br />

15 20 13<br />

15 20 13<br />

121

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

Saved successfully!

Ooh no, something went wrong!