Computer Science EngineeringHard
Dijkstra's algorithm using a binary heap and adjacency lists runs in
- A. O(V^2 log V)
- B. O(VE)
- C. O(E)
- D. O((V+E) log V)
Correct answer: D. O((V+E) log V)
Each edge relaxation may cause a heap update costing log V, plus V extractions.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- For n a power of 2, what is the Theta bound of the loop: x=0; for(i=1;i<=n;i=2) for(j=0;j<i;j++) x++;
- How many leaf nodes does a binary heap stored in an array of 15 elements have?
- A table of size 7 uses h(k) = k mod 7 with linear probing. After inserting 15, 22, 8 and 1 in that order, at which index does key 1 reside?
- The Bellman-Ford single-source shortest path algorithm has running time
- What is the Theta bound of: for(i=1;i<=n;i++) for(j=i;j<=n;j+=i) count++;
- The recurrence T(n) = 4T(n/2) + n^2 has solution