n.******@gmail.com wrote:

- with 10 nodes, give one example of an unbalanced binary tree and

one example of a balanced binary tree

Unbalanced tree: AB,C'K:D'EH:FJ:G: (notation adapted

from Knuth, TAOCP 2.3.3 equation 3)

To balance the tree, put another one on the other pan.

- what is the advantage of having a balanced binary tree over an

unbalanced tree?

Easier access to firewood. When the next high wind topples

the unbalanced tree, the balanced tree that's over it will fall

at the same time and save you the work of cutting it down.

- number your nodes, then give the order in which nodes will be

visited by a depth-first-search

Numbers: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

Depth-first order: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

- explain the differences between traversing the tree pre-order, in-

order and post-order

With pre-order, the pizza is ready when you arrive at the

shop and you needn't wait. With in-order, you may need to pay

a restaurant tax to eat the pizza on the premises. With post-

order, the pizza reaches you three to five business days later

and is unpalatable.

--

Eric Sosman

es*****@acm-dot-org.invalid