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.

C-10.8<br />

Let D be an ordered dictionary with n entries. Show how to modify the AVL<br />

tree to implement the follow<strong>in</strong>g method for D <strong>in</strong> time O(logn):<br />

countAllInRange(k 1 ,k 2 ): Compute <strong>and</strong> return the number of entries <strong>in</strong> D<br />

with key k such that k 1 ≤ k ≤ k 2 .<br />

C-10.9<br />

Show that the nodes that become unbalanced <strong>in</strong> an AVL tree after operation<br />

<strong>in</strong>sertAtExternal is performed, with<strong>in</strong> the execution of an <strong>in</strong>sert<br />

operation, may be nonconsecutive on the path from the newly <strong>in</strong>serted node to<br />

the root.<br />

C-10.10<br />

Show that at most one node <strong>in</strong> an AVL tree becomes unbalanced after operation<br />

removeExternal is performed with<strong>in</strong> the execution of a remove<br />

dictionary operation.<br />

C-10.11<br />

Show that at most one tr<strong>in</strong>ode restructur<strong>in</strong>g operation is needed to restore<br />

balance after any <strong>in</strong>sertion <strong>in</strong> an AVL tree.<br />

C-10.12<br />

Let T <strong>and</strong> U be (2,4) trees stor<strong>in</strong>g n <strong>and</strong> m entries, respectively, such that all the<br />

entries <strong>in</strong> T have keys less than the keys of all the entries <strong>in</strong> U. Describe an<br />

O(logn + logm) time method for jo<strong>in</strong><strong>in</strong>g T<strong>and</strong> U <strong>in</strong>to a s<strong>in</strong>gle tree that stores all<br />

the entries <strong>in</strong> T <strong>and</strong> U.<br />

C-10.13<br />

Repeat the previous problem for red-black trees T <strong>and</strong> U.<br />

C-10.14<br />

Justify Proposition 10.7.<br />

C-10.15<br />

The Boolean <strong>in</strong>dicator used to mark nodes <strong>in</strong> a red-black tree as be<strong>in</strong>g "red" or<br />

"black" is not strictly needed when we have dist<strong>in</strong>ct keys. Describe a scheme for<br />

implement<strong>in</strong>g a red-black tree without add<strong>in</strong>g any extra space to st<strong>and</strong>ard b<strong>in</strong>ary<br />

search tree nodes. How does your scheme affect the search <strong>and</strong> update times?<br />

671

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

Saved successfully!

Ooh no, something went wrong!