Deck 10: Trees

Full screen (f)
exit full mode
Question
A binary search tree is a binary tree with the added property that the left child is less than the parent, which is less than or equal to the ___________.

A) Left child
B) Right child
C) Middle child
D) None of the above
Use Space or
up arrow
down arrow
to flip the card.
Question
The definition of a binary search tree is an extension of the definition of a ______________.

A) stack
B) queue
C) list
D) binary tree
Question
Each BinaryTreeNode object maintains a reference to the element stored at that node as well as references to each of the node's __________.

A) children
B) siblings
C) ancestors
D) None of the above
Question
In removing an element from a binary search tree, another node must be ___________ to replace the node being removed.

A) duplicated
B) demoted
C) promoted
D) None of the above
Question
The leftmost node in a binary search tree will contain the __________ element, while the rightmost node will contain the __________ element.

A) Maximum, minimum
B) Minimum, maximum
C) Minimum, middle
D) None of the above
Question
One of the uses of trees is to provide _________ implementations of other collections.

A) efficient
B) easy
C) useful
D) None of the above
Question
If a binary search tree is not __________, it may be less efficient than a linear structure.

A) complete
B) empty
C) balanced
D) None of the above
Question
The height of the right subtree minus the height of the left subtree is called the ___________ of a node.

A) height
B) balance factor
C) order
D) None of the above
Question
The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order ______.

A) n
B) log n
C) n log n
D) None of the above
Question
The Java Collections API provides two implementations of balanced binary search trees, TreeSet and TreeMap, both of which use a ___________tree implementation.

A) AVL
B) red/black
C) binary search
D) None of the above
Question
A binary ______ tree is a binary tree with the added property that the left child is less than the parent, which is less than or equal to the right child.
Question
The definition of a binary search tree is an ______ of the definition of a binary tree.
Question
Each BinaryTreeNode object maintains a reference to the ______ stored at that node as well as references to each of the node's ______.
Question
In removing an element from a binary search tree, another node must be ______ to replace the node being removed.
Question
The ______ node in a binary search tree will contain the minimum element, while the ______ node will contain the maximum element.
Question
One of the uses of trees is to provide ______ implementations of other collections.
Question
If a binary search tree is not balanced, it may be less ______ than a linear structure.
Question
The height of the right subtree minus the height of the left subtree is called the ______ of a node.
Question
There are only two ways that a tree, or any subtree of a tree, can become ______: through the insertion of a node or through the deletion of a node.
Question
The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order ______.
Question
The Java Collections API provides two implementations of balanced binary search trees, ______ and ______, both of which use a red/black tree implementation.
Question
A binary search tree is a binary tree with the added property that the left child is greater than the parent, which is less than or equal to the right child.
Question
The definition of a binary search tree is an extension of the definition of a binary tree.
Question
Each BinaryTreeNode object maintains a reference to the element stored at that node as well as references to each of the node's children.
Question
In removing an element from a binary search tree, another node must be demoted to replace the node being removed.
Question
The leftmost node in a binary search tree will contain the minimum element, while the rightmost node will contain the maximum element.
Question
One of the uses of trees is to provide simpler implementations of other collections.
Question
If a binary search tree is not balanced, it may be less efficient than a linear structure.
Question
The height of the right subtree minus the height of the left subtree is called the balance factor of a node.
Question
There are only two ways that a tree, or any subtree of a tree, can become unbalanced: through the insertion of a node or through the deletion of a node.
Question
The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order n.
Question
What is the difference between a binary tree and a binary search tree?
Question
Why are we able to specify addElement and removeElement operations for a binary search tree but we were unable to do so for a binary tree?
Question
Assuming that the tree is balanced, what is the time complexity (order) of the addElement operation?
Question
Without the balance assumption, what is the time complexity (order) of the addElement operation?
Question
As stated in this chapter, a degenerate tree might actually be less efficient than a linked list. Why?
Question
Our removeElement operation uses the inorder successor as the replacement for a node with two children. What would be another reasonable choice for the replacement?
Question
The removeAllOccurences operation uses both the contains and removeElement operations. What is the resulting time complexity (order) for this operation?
Question
RemoveFirst and first were O(1) operations for our earlier implementation of an ordered list. Why are they less efficient for our BinarySearchTreeOrderedList?
Question
Why does the BinarySearchTreeOrderedList class have to define the iterator method? Why can it not just rely on the iterator method of its parent class like it does for size and isEmpty?
Question
What is the time complexity of the addElement operation after modifying to implement an AVL tree?
Question
What imbalance is fixed by a single right rotation?
Question
What imbalance is fixed by a leftright rotation?
Question
What is the balance factor of an AVL tree node?
Question
In our discussion of the process for rebalancing an AVL tree, we never discussed the possibility of the balance factor of a node being either +2 or -2 and the balance factor of one of its children being either +2 or -2. Why not?
Question
We noted that the balance restriction for a red/black tree is less strict than that of an AVL tree and yet we still claim that traversing the longest path in a red/black tree is still O(log n). Why?
Question
What is the difference between a TreeSet and a TreeMap?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/47
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Trees
1
A binary search tree is a binary tree with the added property that the left child is less than the parent, which is less than or equal to the ___________.

A) Left child
B) Right child
C) Middle child
D) None of the above
Right child
2
The definition of a binary search tree is an extension of the definition of a ______________.

A) stack
B) queue
C) list
D) binary tree
binary tree
3
Each BinaryTreeNode object maintains a reference to the element stored at that node as well as references to each of the node's __________.

A) children
B) siblings
C) ancestors
D) None of the above
children
4
In removing an element from a binary search tree, another node must be ___________ to replace the node being removed.

A) duplicated
B) demoted
C) promoted
D) None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
5
The leftmost node in a binary search tree will contain the __________ element, while the rightmost node will contain the __________ element.

A) Maximum, minimum
B) Minimum, maximum
C) Minimum, middle
D) None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
6
One of the uses of trees is to provide _________ implementations of other collections.

A) efficient
B) easy
C) useful
D) None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
7
If a binary search tree is not __________, it may be less efficient than a linear structure.

A) complete
B) empty
C) balanced
D) None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
8
The height of the right subtree minus the height of the left subtree is called the ___________ of a node.

A) height
B) balance factor
C) order
D) None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
9
The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order ______.

A) n
B) log n
C) n log n
D) None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
10
The Java Collections API provides two implementations of balanced binary search trees, TreeSet and TreeMap, both of which use a ___________tree implementation.

A) AVL
B) red/black
C) binary search
D) None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
11
A binary ______ tree is a binary tree with the added property that the left child is less than the parent, which is less than or equal to the right child.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
12
The definition of a binary search tree is an ______ of the definition of a binary tree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
13
Each BinaryTreeNode object maintains a reference to the ______ stored at that node as well as references to each of the node's ______.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
14
In removing an element from a binary search tree, another node must be ______ to replace the node being removed.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
15
The ______ node in a binary search tree will contain the minimum element, while the ______ node will contain the maximum element.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
16
One of the uses of trees is to provide ______ implementations of other collections.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
17
If a binary search tree is not balanced, it may be less ______ than a linear structure.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
18
The height of the right subtree minus the height of the left subtree is called the ______ of a node.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
19
There are only two ways that a tree, or any subtree of a tree, can become ______: through the insertion of a node or through the deletion of a node.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
20
The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order ______.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
21
The Java Collections API provides two implementations of balanced binary search trees, ______ and ______, both of which use a red/black tree implementation.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
22
A binary search tree is a binary tree with the added property that the left child is greater than the parent, which is less than or equal to the right child.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
23
The definition of a binary search tree is an extension of the definition of a binary tree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
24
Each BinaryTreeNode object maintains a reference to the element stored at that node as well as references to each of the node's children.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
25
In removing an element from a binary search tree, another node must be demoted to replace the node being removed.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
26
The leftmost node in a binary search tree will contain the minimum element, while the rightmost node will contain the maximum element.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
27
One of the uses of trees is to provide simpler implementations of other collections.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
28
If a binary search tree is not balanced, it may be less efficient than a linear structure.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
29
The height of the right subtree minus the height of the left subtree is called the balance factor of a node.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
30
There are only two ways that a tree, or any subtree of a tree, can become unbalanced: through the insertion of a node or through the deletion of a node.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
31
The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order n.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
32
What is the difference between a binary tree and a binary search tree?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
33
Why are we able to specify addElement and removeElement operations for a binary search tree but we were unable to do so for a binary tree?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
34
Assuming that the tree is balanced, what is the time complexity (order) of the addElement operation?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
35
Without the balance assumption, what is the time complexity (order) of the addElement operation?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
36
As stated in this chapter, a degenerate tree might actually be less efficient than a linked list. Why?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
37
Our removeElement operation uses the inorder successor as the replacement for a node with two children. What would be another reasonable choice for the replacement?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
38
The removeAllOccurences operation uses both the contains and removeElement operations. What is the resulting time complexity (order) for this operation?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
39
RemoveFirst and first were O(1) operations for our earlier implementation of an ordered list. Why are they less efficient for our BinarySearchTreeOrderedList?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
40
Why does the BinarySearchTreeOrderedList class have to define the iterator method? Why can it not just rely on the iterator method of its parent class like it does for size and isEmpty?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
41
What is the time complexity of the addElement operation after modifying to implement an AVL tree?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
42
What imbalance is fixed by a single right rotation?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
43
What imbalance is fixed by a leftright rotation?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
44
What is the balance factor of an AVL tree node?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
45
In our discussion of the process for rebalancing an AVL tree, we never discussed the possibility of the balance factor of a node being either +2 or -2 and the balance factor of one of its children being either +2 or -2. Why not?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
46
We noted that the balance restriction for a red/black tree is less strict than that of an AVL tree and yet we still claim that traversing the longest path in a red/black tree is still O(log n). Why?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
47
What is the difference between a TreeSet and a TreeMap?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 47 flashcards in this deck.