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.

P-7.10<br />

Write a program that visualizes an Euler tour traversal of a proper b<strong>in</strong>ary tree,<br />

<strong>in</strong>clud<strong>in</strong>g the movements from node to node <strong>and</strong> the actions associated with<br />

visits on the left, from below, <strong>and</strong> on the right. Illustrate your program by<br />

hav<strong>in</strong>g it compute <strong>and</strong> display preorder labels, <strong>in</strong>order labels, postorder labels,<br />

ancestor counts, <strong>and</strong> descendent counts for each node <strong>in</strong> the tree (not necessarily<br />

all at the same time).<br />

P-7.11<br />

The arithmetic expression code shown <strong>in</strong> Code Fragments 7.29–7.32 only work<br />

for Integer expressions with the addition operator. Write a <strong>Java</strong> program that<br />

can evaluation arbitrary expressions of any Number type of object.<br />

Chapter Notes<br />

Discussions of the classic preorder, <strong>in</strong>order, <strong>and</strong> postorder tree traversal methods can<br />

be found <strong>in</strong> Knuth's Fundamental <strong>Algorithms</strong> book [62]. The Euler tour traversal<br />

technique comes from the parallel algorithms community, as it is <strong>in</strong>troduced by<br />

Tarjan <strong>and</strong> Vishk<strong>in</strong> [89] <strong>and</strong> is discussed by J´aJ´a [53] <strong>and</strong> by Karp <strong>and</strong><br />

Ramach<strong>and</strong>ran [57]. The algorithm for draw<strong>in</strong>g a tree is generally considered to be a<br />

part of the "folklore" of graph draw<strong>in</strong>g algorithms. The reader <strong>in</strong>terested <strong>in</strong> graph<br />

draw<strong>in</strong>g is referred to works by Tamassia [88] <strong>and</strong> Di Battista et al. [30]. The puzzler<br />

<strong>in</strong> Exercise R-7.10 was communicated by Micha Sharir.<br />

446

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

Saved successfully!

Ooh no, something went wrong!