5e Verified Test Bank Chapter.25 - Tree Implementations - Data Structures with Java 5e Complete Test Bank by Frank M. Carrano. DOCX document preview.
Chapter 25 - Tree Implementations
True/False (11)
- The most common implementation of a tree uses a linked structure.
- A node object in a binary tree references other nodes in the tree.
- A binary tree node references another binary tree.
- Typically, details of the class that represents a node in a tree are hidden from the client.
- Implementing binary tree traversals as iterators makes the code less flexible for the client.
- An iterator object that has not traversed the entire binary tree can be adversely affected by changes to the tree.
- The preorder traversal of a binary tree and a general tree are different.
- The postorder traversal of a general tree is the same as the inorder traversal of a binary tree.
- You can derive an expression tree from the class of basic binary trees.
- A node in a general tree is an object that references its children and a data object.
- You cannot use a binary tree to represent a general tree.
Short Answer (14)
- Write pseudocode for the binary tree method isLeaf() that returns true if the node is a leaf and false if not.
- Show the contents of the stack as an inorder traversal is performed on the following binary tree.
a
empty (a is removed)
b
b c
b (c is removed)
empty (b is removed)
d
d e
d (e is removed)
empty (d is removed)
- Show the contents of the stack as a preorder traversal is performed on the following binary tree.
a
empty (a is removed)
b
empty (b is removed)
d
d c
d (c is removed)
empty (d is removed)
e
empty (e is removed)
- Show the contents of the stack as a postorder traversal is performed on the following binary tree.
a
a b
a b c
a b (c is removed)
a b d
a b d e
a b d (e is removed)
a b (d is removed)
a (b is removed)
empty (a is removed)
- Given the following binary expression tree, what value is returned from the method evaluate in the class ExpressionTree if w = 7, x = 2, y = 1, and z = 8?
- Given the following binary expression tree, what value is returned from the method evaluate in the class ExpressionTree if w = 5, x = 3, y = 7, and z = 8?
- Give the preorder traversal of the following general tree.
- Give the postorder traversal of the following general tree.
- Give the preorder traversal of the following general tree.
- Give the postorder traversal of the following general tree.
- Draw the binary tree that gave the following traversals:
Inorder: Q Y R Z X T
Preorder: T Q Y Z R X
- Draw the binary tree that gave the following traversals:
Postorder: Y Q R X Z T
Inorder: Q Y T R Z X
- Draw the binary tree that gave the following traversals:
Inorder: S A E U Y Q R P D F K L M
Preorder: F A S Q Y E U P R D K L M
- Draw the binary tree that gave the following traversals:
Postorder: S Y U A E R P Q D L K F
Inorder: S A Y U F K Q E R P L D
Multiple Choice (15) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH . YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.
- The most common implementation of a tree uses a(n)
- linked structure
- array
- bag
- priority queue
- The elements in a tree are called
- nodes
- search keys
- entries
- indexes
- In a binary tree, if both the left and right child of a node are null
- the node is a leaf
- the node is the root of the tree
- the node is invalid
- the node contains the key-value pair being searched for
- An iterative version of an inorder traversal for a binary tree uses a(n)
- stack
- queue
- priority queue
- bag
- An iterative version of an preorder traversal for a binary tree uses a(n)
- stack
- queue
- priority queue
- bag
- An iterative version of an postorder traversal for a binary tree uses a(n)
- stack
- queue
- priority queue
- bag
- An iterative version of a level order traversal for a binary tree uses a(n)
- queue
- priority queue
- stack
- bag
- A complete traversal of an n-node binary tree is a(n) _____ operation if visiting a node is O(1) for the recursive implementation.
- O(n)
- O(1)
- O(log n)
- O(n2)
- A complete traversal of an n-node binary tree is a(n) _____ operation if visiting a node is O(1) for the iterative implementation.
- O(n)
- O(1)
- O(log n)
- O(n2)
- A complete traversal of an n-node binary tree is an O(n) operation if visiting a node is _____ for the recursive implementation.
- O(1)
- O(log n)
- O(ln)
- O(n2)
- A complete traversal of an n-node binary tree is an O(n) operation if visiting a node is _____ for the iterative implementation.
- O(1)
- O(log n)
- O(ln)
- O(n2)
- Given the following binary expression tree, what value is returned from the method evaluate in the class ExpressionTree if w = 7, x = 2, y = 1, and z = 8?
- 64
- 16
- 15
- 57
- The postorder traversal of a general tree is the same as the _____ traversal of a binary tree.
- inorder
- postorder
- preorder
- level order
- The preorder traversal of a general tree is the same as the _____ traversal of a binary tree.
- preorder
- postorder
- inorder
- level order
- A node in a binary tree is an object that references a data object and
- two child nodes in the tree
- a linked list containing the child nodes
- a vector containing the list of child nodes
- none of the above
Document Information
Connected Book
Data Structures with Java 5e Complete Test Bank
By Frank M. Carrano