Deck 11: Binary Search Trees

ملء الشاشة (f)
exit full mode
سؤال
A minheap is a complete binary tree in which each node is less than or equal to both the left child and the right child.

A) Minheap
B) Maxheap
C) Heap
D) Binary search tree
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
A minheap stores its smallest element at the ________ of the binary tree.

A) leaf
B) internal node
C) root
D) sibling
سؤال
Both children of the root of a minheap are _________.

A) Minheaps
B) Maxheaps
C) Heaps
D) Binary search trees
سؤال
The __________ method adds a given Comparable element to the appropriate location in the heap, maintaining both the completeness property and the ordering property of the heap.

A) add
B) addNext
C) addElement
D) none of the above
سؤال
Since a heap is a complete tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full.

A) Minheap
B) Maxheap
C) Balanced tree
D) Complete tree
سؤال
Typically, in heap implementations, we keep track of the position of the last node or, more precisely, the last leaf in the tree.

A) root
B) internal node
C) leaf
D) tree
سؤال
To maintain the completeness of the tree, there is only one valid element to replace the ________, and that is the element stored in the last leaf in the tree.

A) root
B) internal node
C) leaf
D) tree
سؤال
Though not a queue at all, a minheap provides an efficient implementation of a _____________.

A) Priority queue
B) Circular queue
C) Deque
D) None of the above
سؤال
Because of the requirement that we be able to traverse up the tree after an insertion, it is necessary for the nodes in a heap to store a pointer to their ________.

A) children
B) parent
C) siblings
D) none of the above
سؤال
In an array implementation of a binary tree, the root of the tree is in position 0, and for each node n, n's left child is in position ________ and n's right child is in position ________.

A) 2n + 1
B) 2n + 2
C) 2(n + 1)
D) A and B
E) A and C
F) B and C
سؤال
The addElement operation for both the linked and array implementations is O(__________).

A) n
B) log n
C) n log n
D) None of the above
سؤال
The removeMin operation for both the linked and array implementations is O(log n).

A) n
B) log n
C) n log n
D) None of the above
سؤال
The __________ method consists of adding each of the elements of the list to a heap and then removing them one at a time.

A) heapSort
B) heapify
C) toString
D) None of the above
سؤال
Heap sort is O(________).

A) n
B) log n
C) n log n
D) None of the above
سؤال
A minheap is a complete ______ tree in which each node is less than or equal to both the left child and the right child.
سؤال
A ______ stores its smallest element at the root of the binary tree.
سؤال
The addElement method adds a given ______ element to the appropriate location in the heap, maintaining both the completeness property and the ordering property of the heap.
سؤال
Since a heap is a ______ tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full.
سؤال
Typically, in ______ implementations, we keep track of the position of the last node or, more precisely, the last leaf in the tree.
سؤال
To maintain the ______ of the tree, there is only one valid element to replace the root, and that is the element stored in the last leaf in the tree.
سؤال
Though not a queue at all, a ______ provides an efficient implementation of a priority queue.
سؤال
Because of the requirement that we be able to traverse up the tree after an insertion, it is necessary for the nodes in a heap to store a pointer to their ______.
سؤال
In an array implementation of a binary tree, the root of the tree is in position 0, and for each node n, n's left child is in position ______ and n's right child is in position ______.
سؤال
The addElement operation for both the linked and array implementations is O(______).
سؤال
The removeMin operation for both the linked and array implementations is O(______)
سؤال
The heapSort method consists of adding each of the elements of the list to a ______ and then removing them one at a time. If the heap is a minheap, this results in ______ order. However, if the heap is a maxheap, this results in ______ order.
سؤال
Heap sort is O(______).
سؤال
A minheap is a complete binary tree in which each node is less than or equal to both the left child and the right child.
سؤال
A minheap stores its largest element at the root of the binary tree, and both children of the root of a minheap are also minheaps.
سؤال
The addElement method adds a given Comparable element to the appropriate location in the heap, maintaining both the completeness property and the ordering property of the heap.
سؤال
Since a heap is a binary search tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full.
سؤال
Typically, in heap implementations, we keep track of the position of the last node or, more precisely, the last leaf in the tree.
سؤال
To maintain the completeness of the tree, there is only one valid element to replace the root, and that is the element stored in the first leaf in the tree.
سؤال
Though not a queue at all, a minheap provides an efficient implementation of a priority queue.
سؤال
Because of the requirement that we be able to traverse up the tree after an insertion, it is necessary for the nodes in a heap to store a pointer to their parent.
سؤال
In an array implementation of a binary tree, the root of the tree is in position 0, and for each node n, n's left child is in position 2(n+1) and n's right child is in position 2(n+2).
سؤال
The addElement operation for both the linked and array implementations is O(n log n).
سؤال
The removeMin operation for both the linked and array implementations is O(log n).
سؤال
The heapSort method consists of adding each of the elements of the list to a heap and then removing them one at a time.
سؤال
Heap sort is O(n log n).
سؤال
What is the difference between a heap (a minheap) and a binary search tree?
سؤال
What is the difference between a minheap and a maxheap?
سؤال
What does it mean for a heap to be complete?
سؤال
Does a heap ever have to be rebalanced?
سؤال
The addElement operation for the linked implementation must determine the parent of the next node to be inserted. Why?
سؤال
Why does the addElement operation for the array implementation not have to determine the parent of the next node to be inserted?
سؤال
The removeMin operation for both implementations replaces the element at the root with the element in the last leaf of the heap. Why is this the proper replacement?
سؤال
What is the time complexity of the addElement operation?
سؤال
What is the time complexity of the removeMin operation?
سؤال
What is the time complexity of heap sort?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 11: Binary Search Trees
1
A minheap is a complete binary tree in which each node is less than or equal to both the left child and the right child.

A) Minheap
B) Maxheap
C) Heap
D) Binary search tree
Minheap
2
A minheap stores its smallest element at the ________ of the binary tree.

A) leaf
B) internal node
C) root
D) sibling
root
3
Both children of the root of a minheap are _________.

A) Minheaps
B) Maxheaps
C) Heaps
D) Binary search trees
Minheaps
4
The __________ method adds a given Comparable element to the appropriate location in the heap, maintaining both the completeness property and the ordering property of the heap.

A) add
B) addNext
C) addElement
D) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
Since a heap is a complete tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full.

A) Minheap
B) Maxheap
C) Balanced tree
D) Complete tree
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
Typically, in heap implementations, we keep track of the position of the last node or, more precisely, the last leaf in the tree.

A) root
B) internal node
C) leaf
D) tree
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
To maintain the completeness of the tree, there is only one valid element to replace the ________, and that is the element stored in the last leaf in the tree.

A) root
B) internal node
C) leaf
D) tree
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
Though not a queue at all, a minheap provides an efficient implementation of a _____________.

A) Priority queue
B) Circular queue
C) Deque
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
Because of the requirement that we be able to traverse up the tree after an insertion, it is necessary for the nodes in a heap to store a pointer to their ________.

A) children
B) parent
C) siblings
D) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
In an array implementation of a binary tree, the root of the tree is in position 0, and for each node n, n's left child is in position ________ and n's right child is in position ________.

A) 2n + 1
B) 2n + 2
C) 2(n + 1)
D) A and B
E) A and C
F) B and C
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
The addElement operation for both the linked and array implementations is O(__________).

A) n
B) log n
C) n log n
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
The removeMin operation for both the linked and array implementations is O(log n).

A) n
B) log n
C) n log n
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
The __________ method consists of adding each of the elements of the list to a heap and then removing them one at a time.

A) heapSort
B) heapify
C) toString
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
Heap sort is O(________).

A) n
B) log n
C) n log n
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
A minheap is a complete ______ tree in which each node is less than or equal to both the left child and the right child.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
A ______ stores its smallest element at the root of the binary tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
The addElement method adds a given ______ element to the appropriate location in the heap, maintaining both the completeness property and the ordering property of the heap.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
Since a heap is a ______ tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
Typically, in ______ implementations, we keep track of the position of the last node or, more precisely, the last leaf in the tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
To maintain the ______ of the tree, there is only one valid element to replace the root, and that is the element stored in the last leaf in the tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
Though not a queue at all, a ______ provides an efficient implementation of a priority queue.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
Because of the requirement that we be able to traverse up the tree after an insertion, it is necessary for the nodes in a heap to store a pointer to their ______.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
In an array implementation of a binary tree, the root of the tree is in position 0, and for each node n, n's left child is in position ______ and n's right child is in position ______.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
The addElement operation for both the linked and array implementations is O(______).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
The removeMin operation for both the linked and array implementations is O(______)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
The heapSort method consists of adding each of the elements of the list to a ______ and then removing them one at a time. If the heap is a minheap, this results in ______ order. However, if the heap is a maxheap, this results in ______ order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
Heap sort is O(______).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
A minheap is a complete binary tree in which each node is less than or equal to both the left child and the right child.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
A minheap stores its largest element at the root of the binary tree, and both children of the root of a minheap are also minheaps.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
The addElement method adds a given Comparable element to the appropriate location in the heap, maintaining both the completeness property and the ordering property of the heap.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
Since a heap is a binary search tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
Typically, in heap implementations, we keep track of the position of the last node or, more precisely, the last leaf in the tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
To maintain the completeness of the tree, there is only one valid element to replace the root, and that is the element stored in the first leaf in the tree.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
Though not a queue at all, a minheap provides an efficient implementation of a priority queue.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
Because of the requirement that we be able to traverse up the tree after an insertion, it is necessary for the nodes in a heap to store a pointer to their parent.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
In an array implementation of a binary tree, the root of the tree is in position 0, and for each node n, n's left child is in position 2(n+1) and n's right child is in position 2(n+2).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
The addElement operation for both the linked and array implementations is O(n log n).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
The removeMin operation for both the linked and array implementations is O(log n).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
The heapSort method consists of adding each of the elements of the list to a heap and then removing them one at a time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
Heap sort is O(n log n).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
What is the difference between a heap (a minheap) and a binary search tree?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
What is the difference between a minheap and a maxheap?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
What does it mean for a heap to be complete?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
Does a heap ever have to be rebalanced?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
The addElement operation for the linked implementation must determine the parent of the next node to be inserted. Why?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
Why does the addElement operation for the array implementation not have to determine the parent of the next node to be inserted?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
The removeMin operation for both implementations replaces the element at the root with the element in the last leaf of the heap. Why is this the proper replacement?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
What is the time complexity of the addElement operation?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
What is the time complexity of the removeMin operation?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
What is the time complexity of heap sort?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.