Deck 12: Self-Balancing Search Trees

Full screen (f)
exit full mode
Question
If a binary search tree were full and contained n items, the expected performance would be O(n).
Use Space or
up arrow
down arrow
to flip the card.
Question
A tree that is self- __________ attempts to achieve a balance so that the height of each left subtree and right subtree are equal or nearly equal.
Question
The cost of insertion in an extremely unbalanced binary search tree can be as high as O(__________).

A) n
B) n log n
C) n2
D) n2log n
Question
The height of an AVL tree is defined as the number of nodes in the longest path from the root to a leaf node, including the root.
Question
In the context of a Left-Left AVL tree, the right subtree of a node has height k and the left subtree has height k + 2. The balance of the node is __________.

A) -2
B) -1
C) 2
D) k
Question
The remedy for a __________ (parent balance is +2, right child balance is +1) AVL tree is to rotate left around parent.

A) Left-Left
B) Right-Right
C) Left-Right
D) Right-Left
Question
The AVL_Tree class derives directly from the __________ class.

A) BTNode
B) Binary_Tree
C) Binary_Search_Tree
D) BST_With_Rotate
Question
Which of the following lines completes the first (non-recursive) case of the AVL_Tree insert function?
If (local_root == NULL) {
Local_root = new AVLNode<Item_Type>(item);
__________
Return true;
}

A) increase = true;
B) increase = false;
C) decrease = true;
D) decrease = false;
Question
Complete the pseudocode for the first cut version of AVL_Tree function rebalance_right.
1. if the right subtree has __________ balance (Right-Left case)
2. Rotate right around the right subtree root.
3. Rotate left.
Question
The rotations performed by the rebalance_left member function of the AVL_Tree class will reduce the overall height of a tree by __________.

A) -1
B) 0
C) 1
D) 2
Question
When we remove an item from a left AVL subtree, the balance of the local root is decreased.
Question
Because each AVL subtree is allowed to be out of balance by ± __________, the tree may contain some holes.

A) 1
B) 2
C) 3
D) 4
Question
On the average, __________ comparisons are required to insert the nth item into an AVL tree.

A) 0.25
B) log2 n
C) log2 n + 0.25
D) n
Question
A Red-Black tree maintains the following invariants:
1. A node is either red or black.
2. The root is always __________.
3. A red node always has black children. (A NULL pointer is considered to refer to a black node.)
4. The number of black nodes in any path from the root to a leaf is the same.
Question
The algorithm for insertion into a Red-Black tree follows the same recursive search process used for all binary search trees to reach the insertion point.
Question
We begin deriving the Red_Black_Tree class from the __________ class.

A) AVL_Tree
B) BST_With_Rotate
C) Binary_Search_Tree
D) Binary_Tree
Question
In a Red-Black tree, we may remove a node only if it is a(n) __________ or if it has only one child.
Question
It can be shown that the upper limit of the height for a Red-Black tree is O(__________).

A) 1
B) log n
C) n
D) n log n
Question
A(n) __________ tree has the additional property that all of the leaves are at the lowest level.
Question
The number of items that a 2-3 tree of height h can hold is between 2h - 1 (all 2-nodes) and __________ (all 3-nodes).
Question
A(n) __________-tree allows up to n children per node, where n may be a very large number.
Question
When comparing a Red-Black tree to a 2-3-4 tree, the 4-node is analogous to a (n) __________ node with two red children.
Question
The __________ of a B-tree is defined as the maximum number of children for a node.
Question
The insertion process for a B-tree is similar to that for a 2-3 or 2-3-4 tree, and each insertion is into a(n) __________.
Question
In a B+, tree the internal nodes contain only keys and pointers to children.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 12: Self-Balancing Search Trees
1
If a binary search tree were full and contained n items, the expected performance would be O(n).
False
2
A tree that is self- __________ attempts to achieve a balance so that the height of each left subtree and right subtree are equal or nearly equal.
balancing
3
The cost of insertion in an extremely unbalanced binary search tree can be as high as O(__________).

A) n
B) n log n
C) n2
D) n2log n
n
4
The height of an AVL tree is defined as the number of nodes in the longest path from the root to a leaf node, including the root.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
In the context of a Left-Left AVL tree, the right subtree of a node has height k and the left subtree has height k + 2. The balance of the node is __________.

A) -2
B) -1
C) 2
D) k
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
The remedy for a __________ (parent balance is +2, right child balance is +1) AVL tree is to rotate left around parent.

A) Left-Left
B) Right-Right
C) Left-Right
D) Right-Left
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
The AVL_Tree class derives directly from the __________ class.

A) BTNode
B) Binary_Tree
C) Binary_Search_Tree
D) BST_With_Rotate
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following lines completes the first (non-recursive) case of the AVL_Tree insert function?
If (local_root == NULL) {
Local_root = new AVLNode<Item_Type>(item);
__________
Return true;
}

A) increase = true;
B) increase = false;
C) decrease = true;
D) decrease = false;
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
Complete the pseudocode for the first cut version of AVL_Tree function rebalance_right.
1. if the right subtree has __________ balance (Right-Left case)
2. Rotate right around the right subtree root.
3. Rotate left.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
The rotations performed by the rebalance_left member function of the AVL_Tree class will reduce the overall height of a tree by __________.

A) -1
B) 0
C) 1
D) 2
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
When we remove an item from a left AVL subtree, the balance of the local root is decreased.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
Because each AVL subtree is allowed to be out of balance by ± __________, the tree may contain some holes.

A) 1
B) 2
C) 3
D) 4
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
On the average, __________ comparisons are required to insert the nth item into an AVL tree.

A) 0.25
B) log2 n
C) log2 n + 0.25
D) n
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
A Red-Black tree maintains the following invariants:
1. A node is either red or black.
2. The root is always __________.
3. A red node always has black children. (A NULL pointer is considered to refer to a black node.)
4. The number of black nodes in any path from the root to a leaf is the same.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
The algorithm for insertion into a Red-Black tree follows the same recursive search process used for all binary search trees to reach the insertion point.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
We begin deriving the Red_Black_Tree class from the __________ class.

A) AVL_Tree
B) BST_With_Rotate
C) Binary_Search_Tree
D) Binary_Tree
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
In a Red-Black tree, we may remove a node only if it is a(n) __________ or if it has only one child.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
It can be shown that the upper limit of the height for a Red-Black tree is O(__________).

A) 1
B) log n
C) n
D) n log n
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
A(n) __________ tree has the additional property that all of the leaves are at the lowest level.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
The number of items that a 2-3 tree of height h can hold is between 2h - 1 (all 2-nodes) and __________ (all 3-nodes).
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
A(n) __________-tree allows up to n children per node, where n may be a very large number.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
When comparing a Red-Black tree to a 2-3-4 tree, the 4-node is analogous to a (n) __________ node with two red children.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
The __________ of a B-tree is defined as the maximum number of children for a node.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
The insertion process for a B-tree is similar to that for a 2-3 or 2-3-4 tree, and each insertion is into a(n) __________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
In a B+, tree the internal nodes contain only keys and pointers to children.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 25 flashcards in this deck.