Deck 12: Tables and Priority Queues

Full screen (f)
exit full mode
Question
In an array-based implementation of the priority queue,the pqDelete operation returns the item in ______.

A)items[size]
B)items[0]
C)items[size-1]
D)items[size+1]
Use Space or
up arrow
down arrow
to flip the card.
Question
In a linear implementation of the priority queue based on a linked list,the item with the highest priority value is located ______.

A)at the beginning of the linked list
B)at the end of the linked list
C)in the middle of the linked list
D)at a random location in the linked list
Question
The ______ operation of the ADT table throws a TableException.

A)tableInsert
B)tableDelete
C)tableRetrieve
D)tableTraverse
Question
In an unsorted array-based implementation of the ADT table,the retrieval operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Question
In an unsorted array-based implementation of the ADT table,the insertion operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Question
Which of the following operations of the binary search tree implementation of the ADT tree is O(n)?

A)insertion
B)deletion
C)retrieval
D)traversal
Question
The sorted array-based implementation of the tableInsert operation is ______.

A)O(1)
B)O(log n)
C)O(n)
D)O(n²)
Question
The sorted reference-based implementation of the tableDelete operation is ______.

A)O(1)
B)O(log n)
C)O(n)
D)O(n²)
Question
A(n)______ implementation of a table is nonlinear.

A)list
B)linked list
C)binary search tree
D)array
Question
In the sorted linear implementation of a table,the proper position of a new item to be inserted is determined ______.

A)by the data type of the item
B)by the size of the item
C)by the value of the item
D)by the value of the search key of the item
Question
The first item to be removed from a priority queue is the item ______.

A)in the front of the priority queue
B)in the end the priority queue
C)with the highest value
D)with the highest priority value
Question
The ADT table is also known as a ______.

A)map
B)queue
C)heap
D)dictionary
Question
The sorted reference-based implementation of the tableInsert operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Question
An array based implementation of an ADT is a ______ implementation.

A)vertical
B)linear
C)nonlinear
D)compound
Question
In an unsorted array-based implementation of a table,a new item is inserted at location ______.

A)items[size]
B)items[size-1]
C)items[size+1]
D)items[size+2]
Question
If the item with a given search key does not exist in a table,the tableRetrieve operation returns ______.

A)the value -1
B)the value 0
C)the value false
D)a null reference
Question
In a binary search tree implementation of the ADT table,the item with the highest priority value is always in the ______.

A)root of the tree
B)leftmost node of the tree
C)rightmost node of the tree
D)leftmost node at level 1 of the tree
Question
A heap in which the root contains the item with the largest search key is called a ______.

A)minheap
B)maxheap
C)complete heap
D)binary heap
Question
Which of the following is true about a linear implementation of a table?

A)the unsorted implementations must insert a new item into its proper position as determined by the value of its search key
B)the sorted implementations can insert a new item into any convenient location
C)the sorted implementations maintain a count of the current number of items in the table
D)the unsorted implementations do not maintain a count of the current number of items in the table
Question
A priority queue orders its items by their ______.

A)position
B)value
C)priority value
D)size
Question
A heap in which the root contains the item with the smallest search key is called a ______.

A)minheap
B)maxheap
C)complete heap
D)binary heap
Question
In an array-based implementation of a heap,the parent of the node in items[i] is always stored in ______.

A)items[i/2]
B)items[(i-1)/2]
C)items[i-2]
D)items[(i-2)/2]
Question
In a maxheap,the root contains a search key greater than or equal to the search key in each of its children.
Question
The ADT table is position-oriented.
Question
In an array-based implementation of a heap,the heapDelete operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Question
A binary search tree implementation of a table is a linear implementation.
Question
In an unsorted reference-based implementation of a table,the tableInsert operation requires a constant time regardless of the table size.
Question
The heapsort is ______ in the worst case.

A)O(n)
B)O(log n)
C)O(n * log n)
D)O(n²)
Question
A heap is a ______.

A)general tree
B)table
C)full binary tree
D)complete binary tree
Question
In an array-based implementation of a heap,the number of array items that must be swapped to transform a semiheap of n nodes into a heap is ______.

A)n
B)n + 1
C)log2ⁿ
D)log2(n + 1)
Question
Which of the following is true about the heapsort?

A)the heapsort does not require a second array
B)the heapsort is more efficient than the mergesort in the worst case
C)the heapsort is more efficient than the mergesort in the average case
D)the heapsort is better than the quicksort in the average case
Question
The ADT table uses a search key to identify its items.
Question
The search key of an item must not change for as long as the item is stored in a table.
Question
The heapsort is ______ in the average case.

A)O(1)
B)O(n)
C)O(log n)
D)O(n * log n)
Question
In an array-based implementation of a heap,the heapInsert operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Question
A binary search tree implementation of the ADT table is easier to understand than a linear implementation.
Question
A semiheap is a ______.

A)table
B)complete binary tree
C)general tree
D)full binary tree
Question
A sorted implementation of a table can insert a new item into any convenient location.
Question
In a heap,the search keys of the children of a particular node have no relationship.
Question
The mergesort is more efficient than the heapsort in the worst case.
Question
What kind of implementation of the ADT table is appropriate for retrieval-dominated applications if the maximum size of the table is NOT known?
Question
What is the effect of the assumption that all items in a table have distinct search keys,on the insertion operation of a table?
Question
What are the four categories of linear implementations of tables?
Question
What does the priority value in a priority queue correspond to in a heap?
Question
Heapsort is a sorting algorithm that uses the heap data structure.Discuss how we can use a binary search tree to sort a list of values.Why would such an algorithm not perform as efficiently as heapsort?
Question
What is a linear implementation?
Question
In the Java Collections Framework,what is the difference between a Collection and a Set?
Question
What is the major advantage that a heap implementation of a priority queue has over a binary search tree implementation?
Question
What are the two main differences between a heap and a binary search tree?
Question
For what kinds of situations is a linear implementation of the ADT table more efficient than a binary search tree implementation?
Question
The Java Collections Framework includes classes called maps such as HashMap and TreeMap.In such classes,the individual elements each have two attributes.What are they?
Question
What are the two possible outcomes of the tableRetrieve operation of the ADT table?
Question
Why is a binary search operation impractical for a reference-based implementation of the ADT table?
Question
How does the pqDelete operation work in a linear implementation of the priority queue based on a linked list?
Question
What is a semiheap?
Question
What are the advantages of a linear implementation of the ADT table over a binary search tree implementation?
Question
In an array-based implementation of the priority queue,where is the item with the highest priority value located?
Question
What function is performed by the tableLength operation of the ADT table?
Question
When implementing an ADT such as a table,one design question is how often each ADT operation is to be performed.Why do we ask ourselves this question?
Question
What kind of implementation of the ADT table is appropriate for retrieval-dominated applications if the maximum size of the table is known?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/60
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 12: Tables and Priority Queues
1
In an array-based implementation of the priority queue,the pqDelete operation returns the item in ______.

A)items[size]
B)items[0]
C)items[size-1]
D)items[size+1]
C
2
In a linear implementation of the priority queue based on a linked list,the item with the highest priority value is located ______.

A)at the beginning of the linked list
B)at the end of the linked list
C)in the middle of the linked list
D)at a random location in the linked list
A
3
The ______ operation of the ADT table throws a TableException.

A)tableInsert
B)tableDelete
C)tableRetrieve
D)tableTraverse
A
4
In an unsorted array-based implementation of the ADT table,the retrieval operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
5
In an unsorted array-based implementation of the ADT table,the insertion operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following operations of the binary search tree implementation of the ADT tree is O(n)?

A)insertion
B)deletion
C)retrieval
D)traversal
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
7
The sorted array-based implementation of the tableInsert operation is ______.

A)O(1)
B)O(log n)
C)O(n)
D)O(n²)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
8
The sorted reference-based implementation of the tableDelete operation is ______.

A)O(1)
B)O(log n)
C)O(n)
D)O(n²)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
9
A(n)______ implementation of a table is nonlinear.

A)list
B)linked list
C)binary search tree
D)array
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
10
In the sorted linear implementation of a table,the proper position of a new item to be inserted is determined ______.

A)by the data type of the item
B)by the size of the item
C)by the value of the item
D)by the value of the search key of the item
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
11
The first item to be removed from a priority queue is the item ______.

A)in the front of the priority queue
B)in the end the priority queue
C)with the highest value
D)with the highest priority value
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
12
The ADT table is also known as a ______.

A)map
B)queue
C)heap
D)dictionary
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
13
The sorted reference-based implementation of the tableInsert operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
14
An array based implementation of an ADT is a ______ implementation.

A)vertical
B)linear
C)nonlinear
D)compound
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
15
In an unsorted array-based implementation of a table,a new item is inserted at location ______.

A)items[size]
B)items[size-1]
C)items[size+1]
D)items[size+2]
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
16
If the item with a given search key does not exist in a table,the tableRetrieve operation returns ______.

A)the value -1
B)the value 0
C)the value false
D)a null reference
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
17
In a binary search tree implementation of the ADT table,the item with the highest priority value is always in the ______.

A)root of the tree
B)leftmost node of the tree
C)rightmost node of the tree
D)leftmost node at level 1 of the tree
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
18
A heap in which the root contains the item with the largest search key is called a ______.

A)minheap
B)maxheap
C)complete heap
D)binary heap
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is true about a linear implementation of a table?

A)the unsorted implementations must insert a new item into its proper position as determined by the value of its search key
B)the sorted implementations can insert a new item into any convenient location
C)the sorted implementations maintain a count of the current number of items in the table
D)the unsorted implementations do not maintain a count of the current number of items in the table
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
20
A priority queue orders its items by their ______.

A)position
B)value
C)priority value
D)size
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
21
A heap in which the root contains the item with the smallest search key is called a ______.

A)minheap
B)maxheap
C)complete heap
D)binary heap
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
22
In an array-based implementation of a heap,the parent of the node in items[i] is always stored in ______.

A)items[i/2]
B)items[(i-1)/2]
C)items[i-2]
D)items[(i-2)/2]
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
23
In a maxheap,the root contains a search key greater than or equal to the search key in each of its children.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
24
The ADT table is position-oriented.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
25
In an array-based implementation of a heap,the heapDelete operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
26
A binary search tree implementation of a table is a linear implementation.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
27
In an unsorted reference-based implementation of a table,the tableInsert operation requires a constant time regardless of the table size.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
28
The heapsort is ______ in the worst case.

A)O(n)
B)O(log n)
C)O(n * log n)
D)O(n²)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
29
A heap is a ______.

A)general tree
B)table
C)full binary tree
D)complete binary tree
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
30
In an array-based implementation of a heap,the number of array items that must be swapped to transform a semiheap of n nodes into a heap is ______.

A)n
B)n + 1
C)log2ⁿ
D)log2(n + 1)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following is true about the heapsort?

A)the heapsort does not require a second array
B)the heapsort is more efficient than the mergesort in the worst case
C)the heapsort is more efficient than the mergesort in the average case
D)the heapsort is better than the quicksort in the average case
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
32
The ADT table uses a search key to identify its items.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
33
The search key of an item must not change for as long as the item is stored in a table.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
34
The heapsort is ______ in the average case.

A)O(1)
B)O(n)
C)O(log n)
D)O(n * log n)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
35
In an array-based implementation of a heap,the heapInsert operation is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
36
A binary search tree implementation of the ADT table is easier to understand than a linear implementation.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
37
A semiheap is a ______.

A)table
B)complete binary tree
C)general tree
D)full binary tree
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
38
A sorted implementation of a table can insert a new item into any convenient location.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
39
In a heap,the search keys of the children of a particular node have no relationship.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
40
The mergesort is more efficient than the heapsort in the worst case.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
41
What kind of implementation of the ADT table is appropriate for retrieval-dominated applications if the maximum size of the table is NOT known?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
42
What is the effect of the assumption that all items in a table have distinct search keys,on the insertion operation of a table?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
43
What are the four categories of linear implementations of tables?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
44
What does the priority value in a priority queue correspond to in a heap?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
45
Heapsort is a sorting algorithm that uses the heap data structure.Discuss how we can use a binary search tree to sort a list of values.Why would such an algorithm not perform as efficiently as heapsort?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
46
What is a linear implementation?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
47
In the Java Collections Framework,what is the difference between a Collection and a Set?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
48
What is the major advantage that a heap implementation of a priority queue has over a binary search tree implementation?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
49
What are the two main differences between a heap and a binary search tree?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
50
For what kinds of situations is a linear implementation of the ADT table more efficient than a binary search tree implementation?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
51
The Java Collections Framework includes classes called maps such as HashMap and TreeMap.In such classes,the individual elements each have two attributes.What are they?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
52
What are the two possible outcomes of the tableRetrieve operation of the ADT table?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
53
Why is a binary search operation impractical for a reference-based implementation of the ADT table?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
54
How does the pqDelete operation work in a linear implementation of the priority queue based on a linked list?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
55
What is a semiheap?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
56
What are the advantages of a linear implementation of the ADT table over a binary search tree implementation?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
57
In an array-based implementation of the priority queue,where is the item with the highest priority value located?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
58
What function is performed by the tableLength operation of the ADT table?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
59
When implementing an ADT such as a table,one design question is how often each ADT operation is to be performed.Why do we ask ourselves this question?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
60
What kind of implementation of the ADT table is appropriate for retrieval-dominated applications if the maximum size of the table is known?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 60 flashcards in this deck.