Ch.28 - Balanced Search Trees Test Bank Docx - Data Structures with Java 5e Complete Test Bank by Frank M. Carrano. DOCX document preview.
Chapter 28 - Balanced Search Trees
True/False (14)
- Every node in a balanced binary tree has subtrees whose heights differ by no more than 1.
- The balance of a binary search tree is not affected when you only add or remove a node.
- A node is balanced if it is the root of a balanced tree.
- In an AVL tree, if the method getHeightDifference returns -1, the left subtree is taller than the right subtree.
- A 2-3 tree tends to be shorter than a binary search tree.
- A 2-3 tree is completely balanced.
- In a 2-3 tree, the last node that splits is a leaf that already contains two entries.
- A 2-4 tree is completely balanced.
- Adding an entry to a 2-3 tree is more efficient than adding an entry to a 2-4 tree.
- When adding a new entry to 2-4 tree, you split any 4-node as soon as you encounter it during the search for the new entry’s position in the tree.
- The root of every red-black tree is red.
- In a red-black tree, every red node has a black parent.
- In a red-black tree, a red node cannot have red children.
- In a red-black tree, adding an entry to a red-black tree results in a new red leaf.
Short Answer (6)
- Starting with the following AVL tree, show the resultant tree after adding a node with the value 7.
Step 1: insert node causing an unbalanced tree
Step 2: after a left rotation on node 6, the node whose subtrees became unbalanced
- Starting with the following AVL tree, show the resultant tree after adding a node with the value 3.
Step1: Insert node causing an unbalanced tree.
Step2: after a left rotation on node 43, the node whose subtrees became unbalanced
- Add the following values to an initially empty 2-3 three. Show each step.
16, 7, 21
- What tree results when you add 19 to the following 2-4 tree?
- What tree results when you add 12 to the following 2-4 tree?
- What tree results when you add 31 to the following 2-4 tree?
Multiple Choice (28) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH . YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.
- A node that is the root of a balanced tree is called a(n) _____ node.
- balanced
- master
- search
- AVL
- The balance of a binary search tree may be compromised when
- a new node is added
- a node is removed
- both a & b
- none of the above
- A node is balanced if its two subtrees differ by no more than
- 1
- 0
- 2
- none of the above
- If the numbers 23, 16, and 34 are added to an empty binary search tree in that order, in order to rebalance it, you need a(n)
- right rotation
- left rotation
- no rotation
- reheap rotation
- If the numbers 5, 13, and 23 are added to an empty binary search tree in that order, in order to rebalance it, you need a(n)
- left rotation
- right rotation
- no rotation
- reheap rotation
- When there is an addition to a node’s left subtree that creates an unbalanced search tree, you can correct it with a(n)
- right rotation
- left rotation
- reheap
- sift up
- When there is an addition to a node’s right subtree that creates an unbalanced search tree, you can correct it with a(n)
- left rotation
- right rotation
- reheap
- sift up
- What type of rotation do you need to rebalance an AVL tree if the addition that unbalanced the tree occurred in the left subtree of node N, the unbalanced node’s left child?
- right rotation
- left rotation
- right-left rotation
- left-right rotation
- What type of rotation do you need to rebalance an AVL tree if the addition that unbalanced the tree occurred in the right subtree of node N, the unbalanced node’s left child?
- left-right rotation
- right-left rotation
- left rotation
- right rotation
- What type of rotation do you need to rebalance an AVL tree if the addition that unbalanced the tree occurred in the left subtree of node N, the unbalanced node’s right child?
- right-left rotation
- left-right rotation
- right rotation
- left rotation
- What type of rotation do you need to rebalance an AVL tree if the addition that unbalanced the tree occurred in the right subtree of node N, the unbalanced node’s right child?
- right rotation
- left rotation
- right-left rotation
- left-right rotation
- In an AVL tree, if the method getHeightDifference returns a value greater than 1,
- the left subtree is taller than the right subtree
- the right subtree is taller than the left subtree
- the tree is balanced
- the tree is unstable
- In an AVL tree, if the method getHeightDifference returns a value less than -1,
- the right subtree is taller than the left subtree
- the left subtree is taller than the right subtree
- the tree is balanced
- the tree is unstable
- In a 2-3 tree, a 2-node contains
- one data item and two children
- two data items and one child
- two data items and three children
- three data items and two children
- In a 2-3 tree, a 3-node contains
- two data items and three children
- three data items and two children
- one data item and two children
- two data items and one child
- A 2-4 tree is a general search tree whose interior nodes must have
- either 2, 3, or 4 children
- either 2 or 4 children
- either 2, 3 or 4 data values
- no 3-nodes
- When adding a new entry to 2-4 tree,
- you split any 4-node as soon as you encounter it during the search for the new entry’s position in the tree
- you split any 4-node on the way back up the search tree
- as soon as it is created
- when there is a collision
- In general, which statement is true?
- 2-4 trees are shorter than 2-3 trees
- 2-4 trees are shorter than AVL trees
- 2-3 tree are shorter than AVL trees
- all of the above
- In general, searching a 2-3 tree has an efficiency of
- O(log n)
- O(n)
- O(1)
- O(n log n)
- In general, searching a 2-4 tree has an efficiency of
- O(log n)
- O(n)
- O(1)
- O(n log n)
- In general, searching an AVL tree has an efficiency of
- O(log n)
- O(n)
- O(1)
- O(n log n)
- A binary tree that is equivalent to a 2-4 tree is called a(n)
- red-black tree
- AVL tree
- 2-3 tree
- 4-2 tree
- Which of the following properties is true for a red-black tree?
- the root is black
- every path from the root to a leaf contains the same number of black nodes
- any children of a red node are black
- all of the above
- Which of the following properties is true for a red-black tree?
- a red node cannot have red children
- the tree is always balanced
- the root is red
- all of the above
- Which of the following properties is true for a red-black tree?
- every red node has a black parent
- the root is red
- red nodes cannot have black children
- all of the above
- In a red-black tree, adding an entry to a red-black tree results in
- a new red leaf
- a new black leaf
- a rotation
- a node split
- In a red-black tree, a 4-node consists of
- a black node and two red children
- a red node and two black children
- a black node and two black children
- a black node, one black child and one red child
- Which search tree does the package java.util use to implement the methods in the interface SortedMap<K, V>?
- a red-black tree
- a 2-4 tree
- a 2-3 tree
- a binary search tree
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