What is the worst case running time of Insert and Extract-min, in an implementation of a priority queue using an unsorted array? Assume that all insertions can be accomodated.
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A. Θ(1), Θ(n)
Explanation
Insert appends at the end in Θ(1); extract-min must scan all n elements, Θ(n).
More Data Structures and Algorithms questions
- In a B-Tree, each node represents a disk block. Suppose one block holds 8192 bytes. Each key uses 32 bytes. In a B-tree of order M there ar…
- Give tight bounds for T(n) = 4T(√n) + lg²n, with T(n) constant for n ≤ 2.
- Consider a weighted directed graph. The current shortest distance from source S to node x is represented by d[x]. Let d[v]= 29, d[u]= 15, w…
- When using Dijkstra's algorithm to find shortest path in a graph, which of the following statement is not true?
- The time complexity to multiply two polynomials of degree n using Fast Fourier transform method is :
- The following multithreaded algorithm computes transpose of a matrix in parallel : p Trans (X, Y, N) if N = 1 ← then Y[1,1] X[1,1] else par…