23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

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.

visited <strong>in</strong> a preorder traversal of H? What about an <strong>in</strong>order traversal of H? What<br />

about a postorder traversal of H?<br />

R-8.15<br />

Show that the sum<br />

which appears <strong>in</strong> the analysis of heap-sort, is Ω(nlogn).<br />

R-8.16<br />

Bill claims that a preorder traversal of a heap will list its keys <strong>in</strong> nonde creas<strong>in</strong>g<br />

order. Draw an example of a heap that proves him wrong.<br />

R-8.17<br />

Hillary claims that a postorder traversal of a heap will list its keys <strong>in</strong> non<br />

<strong>in</strong>creas<strong>in</strong>g order. Draw an example of a heap that proves her wrong.<br />

R-8.18<br />

Show all the steps of the algorithm for remov<strong>in</strong>g key 16 from the heap of Figure<br />

8.3.<br />

R-8.19<br />

Show all the steps of the algorithm for replac<strong>in</strong>g key 5 with 18 <strong>in</strong> the heap of<br />

Figure 8.3.<br />

R-8.20<br />

Draw an example of a heap whose keys are all the odd numbers from 1 to 59<br />

(with no repeats), such that the <strong>in</strong>sertion of an entry with key 32 would cause<br />

up-heap bubbl<strong>in</strong>g to proceed all the way up to a child of the root (replac<strong>in</strong>g that<br />

child's key with 32).<br />

R-8.21<br />

Complete Figure 8.9 by show<strong>in</strong>g all the steps of the <strong>in</strong>-place heap-sort<br />

algorithm. Show both the array <strong>and</strong> the associated heap at the end of each step.<br />

R-8.22<br />

Give a pseudo-code description of a nonrecursive <strong>in</strong>-place heap-sort algorithm.<br />

R-8.23<br />

506

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

Saved successfully!

Ooh no, something went wrong!