EX4
- Consider the tree above. Tell what is described by each of the following phrases:
- The root of the tree
- The leaves of the tree
- The interior nodes of the tree
- The siblings of node 6
- The subtree with root 5
- The ancestors of node 10
- The descendants of node 10
- The nodes to the left of node 10
- The nodes to the right of node 10
- The longest path in the tree
- The height of node 3
- The depth of node 13
- The height of the tree
- For each node in the tree above indicate the leftmost child and the right sibling
- Represent the tree above using leftmost-child right sibling references (draw boxes with arrows).
- Can a leaf in a tree ever have any
- Descendants?
- Proper descendants?
- Suppose we have a graph consisting of four nodes, r, a, b, and c. Node r is an isolated node and has no edges connecting to it. The remaining three nodes form a cycle; that is, we have an edge connecting a and b, and edge connecting b and c, and an edge connecting c and d. Why is this graph not a tree?
- Give expression trees for the following expressions.
- (x + 1) *(x-y+4)
- 1+2+3+4+5+6
- 9*8+7*6+5