Deck 9: Self-Balancing Search Trees

ملء الشاشة (f)
exit full mode
سؤال
Searches into an unbalanced binary search tree are O(log n) not O(n).
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
If a node is balanced, insertion into its left subtree will cause it to become left-heavy, and its height will also increase by 2.
سؤال
All the leaves of a 2-3 node are at the lowest level.
سؤال
The easiest way to keep a tree balanced is to always add nodes to the left subtree.
سؤال
Red nodes do not affect a Red-Black tree's balance.
سؤال
The average cost of a search in a(n) ____________________ tree built from random values is 1.002 log2n.
سؤال
The Java API has a(n) ____________________ class that implements a Red-Black tree.
سؤال
A(n) ____ tree is made up of nodes designated as 2-nodes and 3-nodes.
سؤال
A(n) ____________________ tree is one in which the root and the left subtree of the root are both left-heavy.
سؤال
With respect to binary search tree, if the right subtree has a height of k, its left subtree has a height of 2, its factor is ____________________.
سؤال
The ____________________ of a tree is the number of nodes in the longest path from the root node to a leaf node, including the root.
سؤال
A(n) ____________________ contains two data fields, ordered so that the first is less than the second, and references to three children: one child containing values less than the first data field, one child containing values between the two data fields, and one child containing values greater than the second data field.
سؤال
____________________ trees expand on the idea of 2-3 trees by adding the 4-node.
سؤال
A Red-Black tree is a binary-tree equivalent of a(n) ____________________ tree.
سؤال
A(n) ____________________ extends the idea behind the 2-3 and 2-3-4 trees by allowing a maximum of CAP data items in each node.
سؤال
____ were developed to store indexes to databases on disk storage.

A) 2-3 trees
B) 2-3-4 trees
C) Red-Black trees
D) B-trees
سؤال
Which of the following is the algorithm for Rotation Right (unbalanced search tree)?

A) Remember the value of root.left (temp = root.left).
Set root.left to the value of root.left.right.
Set temp.left to root.
Set root to right.
B) Remember the value of root.left (temp = root.right).
Set root.right to the value of root.right.left.
Set temp.right to root.
Set root to temp.
C) Remember the value of root.left (temp = root.left).
Set root.left to the value of root.left.right.
Set temp.left to root.
Set temp to root.
D) Remember the value of root.left (temp = root.left).
Set root.left to the value of root.left.right.
Set temp.right to root.
Set root to temp.
سؤال
How would you rebalance a Left-Left tree?

A) Rotate right around parent.
B) Rotate left around child, then rotate right around parent.
C) Rotate left around parent.
D) Rotate right around child, then rotate left around parent.
سؤال
How would you rebalance a Right-Right tree?

A) Rotate right around parent.
B) Rotate left around child, then rotate right around parent.
C) Rotate left around parent.
D) Rotate right around child, then rotate left around parent.
سؤال
Which of the following is the complete algorithm for insertion into an AVL tree?

A) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data
3. The item is already in the tree; return false.
B) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data 3. The item is already in the tree; return false. else if the item is greater than root.data 4. The processing is symmetric to Steps1 through 3. Note that balance is incremented if increase is true.
C) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data
3. The item is already in the tree; return false.
else if the item is less than root.data
4. Recursively insert the item in the left subtree.
5.if the height of the left subtree has increased (increased is true)
6. Decrement balance.
7. if balance is zero, reset increase to false.
8. if balance is less than -1
9. Reset increase to false.
10. Perform a rebalanceLeft.
else if the item is greater than root.data
11. The processing is symmetric to Steps 4 through 10. Note that balance is incremented if increase is true.
D) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data
3. The item is already in the tree; return false.
4. Recursively insert the item in the left subtree. else if the item is greater than root.data
5. The processing is symmetric to Steps 1 through 4. Note that balance is incremented if increase is true.
سؤال
The following is the algorithm for ____.
<strong>The following is the algorithm for ____.  </strong> A) rotation right B) rebalanceLeft (AVL tree) C) rotation left D) rebalanceRight (AVL tree) <div style=padding-top: 35px>

A) rotation right
B) rebalanceLeft (AVL tree)
C) rotation left
D) rebalanceRight (AVL tree)
سؤال
The height of a 2-3 tree is between ____.

A) O(log n) and n
B) O(1) and O(n)
C) O(n) and O(n2)
D) log3n and log2n
سؤال
A(n) ____ can be represented as either a black node with a left red child or a black node with a right red child.

A) 2-node
B) 3-node
C) 4-node
D) 5-node
سؤال
With respect to Red-Black trees, which of the following is correct?

A) Nodes are always black.
B) The root is always red.
C) A red node always has red children.
D) The number of black nodes in any path from the root to a leaf is the same.
سؤال
The formula ____ is used to calculate the balance for each node of a binary search tree.

A) hR - hL
B) hR + hL
C) (hR - hL) *2
D) hR * hL
سؤال
A skip-list provides performance that is comparable to a balanced binary search tree.
سؤال
All nodes in a skip-list have the same number of links.
سؤال
The level of a node in a skip-list is determined by a random process.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/28
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Self-Balancing Search Trees
1
Searches into an unbalanced binary search tree are O(log n) not O(n).
False
2
If a node is balanced, insertion into its left subtree will cause it to become left-heavy, and its height will also increase by 2.
False
3
All the leaves of a 2-3 node are at the lowest level.
True
4
The easiest way to keep a tree balanced is to always add nodes to the left subtree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
5
Red nodes do not affect a Red-Black tree's balance.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
6
The average cost of a search in a(n) ____________________ tree built from random values is 1.002 log2n.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
7
The Java API has a(n) ____________________ class that implements a Red-Black tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
8
A(n) ____ tree is made up of nodes designated as 2-nodes and 3-nodes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
9
A(n) ____________________ tree is one in which the root and the left subtree of the root are both left-heavy.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
10
With respect to binary search tree, if the right subtree has a height of k, its left subtree has a height of 2, its factor is ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
11
The ____________________ of a tree is the number of nodes in the longest path from the root node to a leaf node, including the root.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
12
A(n) ____________________ contains two data fields, ordered so that the first is less than the second, and references to three children: one child containing values less than the first data field, one child containing values between the two data fields, and one child containing values greater than the second data field.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
13
____________________ trees expand on the idea of 2-3 trees by adding the 4-node.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
14
A Red-Black tree is a binary-tree equivalent of a(n) ____________________ tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
15
A(n) ____________________ extends the idea behind the 2-3 and 2-3-4 trees by allowing a maximum of CAP data items in each node.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
16
____ were developed to store indexes to databases on disk storage.

A) 2-3 trees
B) 2-3-4 trees
C) Red-Black trees
D) B-trees
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following is the algorithm for Rotation Right (unbalanced search tree)?

A) Remember the value of root.left (temp = root.left).
Set root.left to the value of root.left.right.
Set temp.left to root.
Set root to right.
B) Remember the value of root.left (temp = root.right).
Set root.right to the value of root.right.left.
Set temp.right to root.
Set root to temp.
C) Remember the value of root.left (temp = root.left).
Set root.left to the value of root.left.right.
Set temp.left to root.
Set temp to root.
D) Remember the value of root.left (temp = root.left).
Set root.left to the value of root.left.right.
Set temp.right to root.
Set root to temp.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
18
How would you rebalance a Left-Left tree?

A) Rotate right around parent.
B) Rotate left around child, then rotate right around parent.
C) Rotate left around parent.
D) Rotate right around child, then rotate left around parent.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
19
How would you rebalance a Right-Right tree?

A) Rotate right around parent.
B) Rotate left around child, then rotate right around parent.
C) Rotate left around parent.
D) Rotate right around child, then rotate left around parent.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
20
Which of the following is the complete algorithm for insertion into an AVL tree?

A) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data
3. The item is already in the tree; return false.
B) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data 3. The item is already in the tree; return false. else if the item is greater than root.data 4. The processing is symmetric to Steps1 through 3. Note that balance is incremented if increase is true.
C) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data
3. The item is already in the tree; return false.
else if the item is less than root.data
4. Recursively insert the item in the left subtree.
5.if the height of the left subtree has increased (increased is true)
6. Decrement balance.
7. if balance is zero, reset increase to false.
8. if balance is less than -1
9. Reset increase to false.
10. Perform a rebalanceLeft.
else if the item is greater than root.data
11. The processing is symmetric to Steps 4 through 10. Note that balance is incremented if increase is true.
D) 1. if the root is null
2. Create a new tree with the item at the root and return true.
else if the item is equal to root.data
3. The item is already in the tree; return false.
4. Recursively insert the item in the left subtree. else if the item is greater than root.data
5. The processing is symmetric to Steps 1 through 4. Note that balance is incremented if increase is true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
21
The following is the algorithm for ____.
<strong>The following is the algorithm for ____.  </strong> A) rotation right B) rebalanceLeft (AVL tree) C) rotation left D) rebalanceRight (AVL tree)

A) rotation right
B) rebalanceLeft (AVL tree)
C) rotation left
D) rebalanceRight (AVL tree)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
22
The height of a 2-3 tree is between ____.

A) O(log n) and n
B) O(1) and O(n)
C) O(n) and O(n2)
D) log3n and log2n
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
23
A(n) ____ can be represented as either a black node with a left red child or a black node with a right red child.

A) 2-node
B) 3-node
C) 4-node
D) 5-node
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
24
With respect to Red-Black trees, which of the following is correct?

A) Nodes are always black.
B) The root is always red.
C) A red node always has red children.
D) The number of black nodes in any path from the root to a leaf is the same.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
25
The formula ____ is used to calculate the balance for each node of a binary search tree.

A) hR - hL
B) hR + hL
C) (hR - hL) *2
D) hR * hL
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
26
A skip-list provides performance that is comparable to a balanced binary search tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
27
All nodes in a skip-list have the same number of links.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
28
The level of a node in a skip-list is determined by a random process.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 28 في هذه المجموعة.