Test Bank Chapter 26 - A Binary Search Tree Implementation - Data Structures with Java 5e Complete Test Bank by Frank M. Carrano. DOCX document preview.
Chapter 26 - A Binary Search Tree Implementation
True/False (8)
- The shape of a binary search tree affects the efficiency of the simple recursive search algorithm.
- You can create different binary search trees from the same data.
- Binary search trees are not an efficient choice for searching if the data tends to remain stable.
- Searching a binary search tree is like performing a binary search of an array.
- Every addition to a binary search tree adds a new root.
- When adding an entry to a binary search tree, the search ends at a leaf if the entry is not already in the tree.
- For best performance, when you add entries to a binary search tree, you should add them in sorted order.
- You can implement the ADT dictionary using a binary search tree.
Short Answer (11)
- Why can’t the two setTree methods that are inherited from BinaryTree be used in the class BinrarySearchTree?
- How does the class BinarySearchTree handle the two setTree methods that are inherited from BinaryTree?
- Write a pseudo code algorithm for searching a binary search tree.
return false
else if (object being searched for is equal to the root of the tree)
return true
else if (object being searched for is less than the root of the tree)
recursively call the search algorithm on the left subtree
else
recursively call the search algorithm on the right subtree
- Draw the binary search tree from the following input.
4, 10, 12, 54, 19, 27, 7, 2
- Given the following binary search tree, draw the tree after adding 3.
- Given the following binary search tree, draw the tree after adding 9.
- How do you remove a node that is a leaf in a binary search tree?
- When you add entries to a binary search tree, if possible, you should not add them in sorted order. Explain.
- Given the following binary search tree, draw the tree after deleting the node with the value 55.
- Given the following binary search tree, draw the tree after deleting the node with the value 35.
- Given the following binary search tree, draw the tree after deleting the node with the value 5.
Multiple Choice (27) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH . YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.
- The data in a node’s _____ subtree are less than the data in a node’s _____ subtree.
- left, right
- right, left
- left, middle
- middle, right
- In the interface SearchTreeInterface, what does the method getEntry return if the object being sought doesn’t exist?
- null
- false
- 0
- throws an exception
- In the interface SearchTreeInterface, what does the method remove return if the object being sought doesn’t exist?
- null
- false
- 0
- throws an exception
- In the interface SearchTreeInterface, what does the method add return if the object being added doesn’t exist?
- null
- false
- 0
- throws an exception
- In the interface SearchTreeInterface, what does the method add return if the object being added already exists in the tree?
- the existing entry that matched the parameter
- true
- 1
- throws an exception
- In the interface SearchTreeInterface, the method getEntry returns an object in the tree that matches the given entry according to the entry’s _____ method.
- compareTo
- equalTo
- equals
- same
- In a binary search tree, the getInorderIterator inherited from the class BinaryTree sorts data
- in ascending order
- in descending order
- in striped order
- none of the above
- Every addition to a binary search tree adds a new
- leaf
- parent
- ancestor
- root
- If a node x is the inorder predecessor of node y then node x must appear in y’s _____ subtree.
- left
- right
- middle
- all of the above
- If a node x is the inorder successor of node y then node x must appear in y’s _____ subtree.
- right
- left
- middle
- all of the above
- The inorder predecessor of a node N is
- the largest entry in N’s left subtree
- the largest entry in N’s right subtree
- the smallest entry in N’s left subtree
- the smallest entry in N’s right subtree
- The inorder successor of a node N is
- the smallest entry in N’s right subtree
- the smallest entry in N’s left subtree
- the largest entry in N’s right subtree
- the largest entry in N’s left subtree
- The largest entry in a node N’s left subtree is
- the subtree’s rightmost node
- the subtree’s leftmost node
- the left child of N
- the right child of N
- The largest entry in a node N’s right subtree is
- the subtree’s rightmost node
- the subtree’s leftmost node
- the left child of N
- the right child of N
- The smallest entry in a node N’s left subtree is
- the subtree’s leftmost node
- the subtree’s rightmost node
- the left child of N
- the right child of N
- The smallest entry in a node N’s right subtree is
- the subtree’s leftmost node
- the subtree’s rightmost node
- the left child of N
- the right child of N
- When adding an entry to a binary search tree, when does the search end?
- when the item is found
- at a leaf if the entry is not already in the tree
- both a & b
- none of the above
- Given a binary search tree with n nodes and height h, what is the maximum number of comparisons that each operation requires for the method add?
- O(h)
- O(n)
- O(log h)
- O(1)
- Given a binary search tree with n nodes and height h, what is the maximum number of comparisons that each operation requires for the method remove?
- O(h)
- O(n)
- O(log h)
- O(1)
- Given a binary search tree with n nodes and height h, what is the maximum number of comparisons that each operation requires for the method getEntry?
- O(h)
- O(n)
- O(log h)
- O(1)
- The maximum possible height of a binary search tree with n nodes is
- n
- log n
- n2
- n-2
- What is the worst-case performance of the add method in a binary search tree with linked nodes?
- O(n)
- O(1)
- O(log n)
- O(n2)
- What is the worst-case performance of the remove method in a binary search tree with linked nodes?
- O(n)
- O(1)
- O(log n)
- O(n2)
- What is the worst-case performance of the getEntry method in a binary search tree with linked nodes?
- O(n)
- O(1)
- O(log n)
- O(n2)
- What is the worst-case performance of the add method in a full binary search tree with linked nodes?
- O(log n)
- O(n)
- O(1)
- O(n2)
- What is the worst-case performance of the remove method in a full binary search tree with linked nodes?
- O(log n)
- O(n)
- O(1)
- O(n2)
- What is the worst-case performance of the getEntry method in a full binary search tree with linked nodes?
- O(log n)
- O(n)
- O(1)
- O(n2)
Document Information
Connected Book
Data Structures with Java 5e Complete Test Bank
By Frank M. Carrano
Test Bank
General
View Product →
Explore recommendations drawn directly from what you're reading
Quick Navigation
Benefits
Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party