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.

c.<br />

Let T be a proper b<strong>in</strong>ary tree with height h <strong>and</strong> n nodes. Show that<br />

log(n + 1) −1 ≤ h ≤ (n − 1)/2.<br />

d.<br />

For which values of n <strong>and</strong> h can the above lower <strong>and</strong> upper bounds on h be<br />

atta<strong>in</strong>ed with equality?<br />

R-7.16<br />

Describe a generalization of the Euler tour traversal to trees such that each<br />

<strong>in</strong>ternal node has three children. Describe how you could use this traversal to<br />

compute the height of each node <strong>in</strong> such a tree.<br />

R-7.17<br />

Compute the output of algorithm toStr<strong>in</strong>gPostorder(T,T.root()), from<br />

Code Fragment 7.12, on the tree T of Figure 7.3.<br />

R-7.18<br />

Illustrate the execution of algorithm diskSpace(T, T.root()) (Code<br />

Fragment 7.13) on the tree T of Figure 7.9.<br />

R-7.19<br />

Let T be the b<strong>in</strong>ary tree of Figure 7.11.<br />

a.<br />

Give the output of toStr<strong>in</strong>gPostorder(T, T.root()) (Code Fragment<br />

7.9).<br />

b.<br />

Give the output of parentheticRepresentation(T, T.root())<br />

(Code Fragment 7.10).<br />

R-7.20<br />

Let T be the b<strong>in</strong>ary tree of Figure 7.11.<br />

a.<br />

Give the output of toStr<strong>in</strong>gPostorder(T, T.root()) (Code Fragment<br />

7.12).<br />

435

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

Saved successfully!

Ooh no, something went wrong!