Q. What is the space complexity of a binary heap storing n elements?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
The space complexity of a binary heap storing n elements is O(n) because it needs to store all n elements.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a binary heap?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
The space complexity of a binary heap is O(n) because it stores n elements in an array.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of building a binary heap from an array of n elements?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(n^2)
Show solution
Solution
Building a binary heap from an array can be done in O(n) time using the heapify process.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the time complexity of building a heap from an array of n elements?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(n^2)
Show solution
Solution
Building a heap from an array can be done in O(n) time using the heapify process.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the time complexity of deleting the maximum element from a max-heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Deleting the maximum element from a max-heap involves removing the root and then re-heapifying, which takes O(log n) time.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of extracting the minimum element from a min-heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Extracting the minimum element from a min-heap requires restructuring the heap, which takes O(log n) time.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of inserting an element into a binary heap used as a priority queue?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Inserting an element into a binary heap takes O(log n) time due to the need to maintain the heap property.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of inserting an element into a binary heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Inserting an element into a binary heap requires maintaining the heap property, which takes O(log n) time.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of inserting an element into a hash table in the average case?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
In the average case, inserting an element into a hash table has a time complexity of O(1) due to direct indexing.
Correct Answer:
C
— O(1)
Learn More →
Q. What is the time complexity of removing the highest priority element from a binary heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Removing the highest priority element from a binary heap has a time complexity of O(log n) due to the need to re-heapify.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of removing the highest priority element from a priority queue implemented with a binary heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Removing the highest priority element from a binary heap takes O(log n) time due to the need to maintain the heap property after removal.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of searching for an element in a hash table in the average case?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
In the average case, searching for an element in a hash table has a time complexity of O(1) due to direct indexing.
Correct Answer:
C
— O(1)
Learn More →
Q. What is the time complexity of searching for an element in a hash table on average?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n^2)
Show solution
Solution
On average, searching for an element in a hash table has a time complexity of O(1) due to direct access via the hash function.
Correct Answer:
C
— O(1)
Learn More →
Q. What is the time complexity of searching for an element in a well-designed hash table?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
In a well-designed hash table, the average time complexity for searching is O(1), assuming a good hash function and low collision rate.
Correct Answer:
C
— O(1)
Learn More →
Q. What is the time complexity of the 'find' operation in a Disjoint Set Union with path compression?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(α(n))
Show solution
Solution
The time complexity of the 'find' operation in a Disjoint Set Union with path compression is O(α(n)), where α is the inverse Ackermann function.
Correct Answer:
D
— O(α(n))
Learn More →
Q. What is the time complexity of the 'find' operation in a well-optimized Disjoint Set Union with path compression?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(α(n))
Show solution
Solution
The time complexity of the 'find' operation in a well-optimized Disjoint Set Union with path compression is O(α(n)), where α is the inverse Ackermann function.
Correct Answer:
D
— O(α(n))
Learn More →
Q. What is the time complexity of the 'Find' operation with path compression and union by rank?
A.
O(n)
B.
O(log n)
C.
O(α(n))
D.
O(1)
Show solution
Solution
The time complexity of the 'Find' operation with path compression and union by rank is O(α(n)), where α is the inverse Ackermann function.
Correct Answer:
C
— O(α(n))
Learn More →
Q. What is the time complexity of the 'Find' operation with path compression in Disjoint Set Union?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(α(n))
Show solution
Solution
The time complexity of the 'Find' operation with path compression in Disjoint Set Union is O(α(n)), where α is the inverse Ackermann function.
Correct Answer:
D
— O(α(n))
Learn More →
Q. What is the time complexity of the 'Union' operation in an optimized Disjoint Set Union with path compression and union by rank?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(α(n))
Show solution
Solution
The time complexity of the 'Union' operation in an optimized Disjoint Set Union with path compression and union by rank is O(α(n)), where α is the inverse Ackermann function.
Correct Answer:
D
— O(α(n))
Learn More →
Q. What is the time complexity of the 'Union' operation in an optimized Disjoint Set Union with path compression?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(α(n))
Show solution
Solution
The time complexity of the 'Union' operation in an optimized Disjoint Set Union with path compression is O(α(n)), where α is the inverse Ackermann function.
Correct Answer:
D
— O(α(n))
Learn More →
Q. What is the worst-case time complexity for a sequence of m union and find operations in Disjoint Set Union with path compression and union by rank?
A.
O(m)
B.
O(m log n)
C.
O(m α(n))
D.
O(n)
Show solution
Solution
The worst-case time complexity for a sequence of m union and find operations in Disjoint Set Union with path compression and union by rank is O(m α(n)).
Correct Answer:
C
— O(m α(n))
Learn More →
Q. What is the worst-case time complexity for building a heap from an array of n elements?
A.
O(n)
B.
O(n log n)
C.
O(log n)
D.
O(1)
Show solution
Solution
The worst-case time complexity for building a heap from an array of n elements is O(n) using the heapify process.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the worst-case time complexity for deleting the minimum element from a binary min-heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Deleting the minimum element from a binary min-heap requires re-structuring the heap, which takes O(log n) time.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the worst-case time complexity for deleting the minimum element from a binary heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Deleting the minimum element from a binary heap takes O(log n) time as it requires re-heapifying the structure.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the worst-case time complexity for deleting the minimum element from a min-heap?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
Deleting the minimum element from a min-heap involves removing the root and then re-heapifying, which takes O(log n) time.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the worst-case time complexity for searching in a hash table with chaining?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
In the worst case, if all keys hash to the same index, searching in a hash table with chaining can take O(n) time.
Correct Answer:
C
— O(n)
Learn More →
Q. What is the worst-case time complexity of the 'Union' operation in Disjoint Set Union with union by rank?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(α(n))
Show solution
Solution
The worst-case time complexity of the 'Union' operation in Disjoint Set Union with union by rank is O(α(n)).
Correct Answer:
D
— O(α(n))
Learn More →
Q. What is the worst-case time complexity of the union operation in a basic Disjoint Set Union without optimizations?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n^2)
Show solution
Solution
The worst-case time complexity of the union operation in a basic Disjoint Set Union without optimizations is O(n).
Correct Answer:
C
— O(n)
Learn More →
Q. What technique is commonly used in Disjoint Set Union to optimize the 'Find' operation?
A.
Binary Search
B.
Path Compression
C.
Merge Sort
D.
Heapify
Show solution
Solution
Path Compression is a technique used in Disjoint Set Union to optimize the 'Find' operation by flattening the structure of the tree whenever 'Find' is called.
Correct Answer:
B
— Path Compression
Learn More →
Q. What technique is commonly used to optimize the 'Find' operation in Disjoint Set Union?
A.
Binary Search
B.
Path Compression
C.
Merge Sort
D.
Heapify
Show solution
Solution
Path Compression is a technique used to optimize the 'Find' operation by flattening the structure of the tree whenever 'Find' is called.
Correct Answer:
B
— Path Compression
Learn More →
Showing 91 to 120 of 182 (7 Pages)