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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

T is a (2,4) tree.<br />

c.<br />

T is a red-black tree.<br />

d.<br />

T is a splay tree.<br />

e.<br />

T is a b<strong>in</strong>ary search tree.<br />

R-10.21<br />

Perform the follow<strong>in</strong>g sequence of operations <strong>in</strong> an <strong>in</strong>itially empty splay tree<br />

<strong>and</strong> draw the tree after each set of operations.<br />

a.<br />

Insert keys 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, <strong>in</strong> this order.<br />

b.<br />

Search for keys 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, <strong>in</strong> this order.<br />

c.<br />

Delete keys 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, <strong>in</strong> this order.<br />

R-10.22<br />

What does a splay tree look like if its entries are accessed <strong>in</strong> <strong>in</strong>creas<strong>in</strong>g order by<br />

their keys?<br />

R-10.23<br />

Expla<strong>in</strong> how to use an AVL tree or a red-black tree to sort n comparable<br />

elements <strong>in</strong> O(nlogn) time <strong>in</strong> the worst case.<br />

R-10.24<br />

Can we use a splay tree to sort n comparable elements <strong>in</strong> O(nlogn) time <strong>in</strong> the<br />

worst case? Why or why not?<br />

Creativity<br />

669

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

Saved successfully!

Ooh no, something went wrong!