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.

R-7.11<br />

Let T be an ordered tree with more than one node. Is it possible that the preorder<br />

traversal of T visits the nodes <strong>in</strong> the same order as the postorder traversal of T?<br />

If so, give an example; otherwise, argue why this cannot occur. Likewise, is it<br />

possible that the preorder traversal of T visits the nodes <strong>in</strong> the reverse order of<br />

the postorder traversal of T? If so, give an example; otherwise, argue why this<br />

cannot occur.<br />

R-7.12<br />

Answer the previous question for the case when T is a proper b<strong>in</strong>ary tree with<br />

more than one node.<br />

R-7.13<br />

What is the runn<strong>in</strong>g time of parentheticRepresentation(T, T.root())<br />

(Code Fragment 7.10) for a tree T with n nodes?<br />

R-7.14<br />

Draw a (s<strong>in</strong>gle) b<strong>in</strong>ary tree T such that<br />

•<br />

Each <strong>in</strong>ternal node of T stores a s<strong>in</strong>gle character<br />

•<br />

A preorder traversal of T yields EXAMFUN<br />

•<br />

R-7.15<br />

An <strong>in</strong>order traversal of T yields MAFXUEN.<br />

Answer the follow<strong>in</strong>g questions so as to justify Proposition 7.10.<br />

a.<br />

What is the m<strong>in</strong>imum number of external nodes for a proper b<strong>in</strong>ary tree with<br />

height h? Justify your answer.<br />

b.<br />

What is the maximum number of external nodes for a proper b<strong>in</strong>ary tree<br />

with height h? Justify your answer.<br />

434

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

Saved successfully!

Ooh no, something went wrong!