in Others edited by
1,520 views
0 votes
0 votes

The time required to find the shortest path in a graph with $n$ vertices and $e$ edges is:

  1. $O(e)$
  2. $O(n)$
  3. $O(e^{2})$
  4. $O(n^{2})$
in Others edited by
1.5k views

1 comment

If the Graph is represented using Adjacency Matrix, it is $ O(V^2) $ . If the input graph is represented using adjacency list it can be reduced to $O(E log V)$ with the help of binary heap.

 Just replace E by $e$ and V by $ n$ to get your answer
1
1

3 Answers

0 votes
0 votes
answer is option D
0 votes
0 votes
Dijktra's algorithm's time complexity is     V.log(V) + E  (using fibonacci heaps). They have given #edges as 'e'. Now, 'e' can be equal to V*V. Also, the notation being used is big-O. So, answer is (D).
0 votes
0 votes
Undirected graph

BFS=O(V+E)=O(n+e)

Directed graph

dijkstra algorithm with list = O($V^{2}$)=O($n^{2}$)

dijkstra algorithm with binary heap=O((E+V)LOGV)=O((e+n)log(n))

dijkstra algorithm with fibbonacci heap=O((E+VLOGV)=O((e+nlog(n))

Bellman ford algorithm=O(VE)=(ne)

ANSWER SHOULD BE OPTION D

Related questions