Java Software Structures, 4th Edition Exercise Solutions, Ch. 10
Chapter 10 Exercise Solutions
EX 10.1 Develop a pseudocode algorithm for a level-order traversal of a binary tree.
Create a new queue(traversalQueue) and add the root to the queue
Create a list(resultsList) to hold the resulting traversal
EX 10.2 Draw either a matrilineage (following your mother’s lineage) or a patrilineage (following
your father’s lineage) diagram for a couple of generations. Develop a pseudocode
algorithm for inserting a person into their proper place in the tree.
EX 10.3 Develop a pseudocode algorithm to build an expression tree from a prefix expression.
Create an expressiontree stack
Create an operator stack
While there is input
{
get the next term
if the term is an operand
}
While the operator stack is not empty
{
pop one operator from the operator stack
pop two nodes from the expression tree stack