For Dijkstra’s shortest path algorithm:
a. Give the Big-O time for Dijkstra’s shortest path algorithm and
explain your answer.
b. Does the answer to (a) depend on whether we use an adjacency
matrix or list? Explain your answer.
a.
The Big-O time of Dijkstra's algorithm depends upon the data structure used in algorithm.
Mostly and mainly MinHeap(Priority Queue) is used.
//Pseudocode of Dijkstra's algorithm

Using MinHeap and Adjacency list representation of graph, Time complextity of Dijkstra's algorithm = O(n) + O(n) + O(n logn) + O(e) + O(e logn) = O( n + e logn )
For sparse matrix, e = O(n)
For dense matrix, e = O(n2)
So we can say, in best case O( n logn ) is time complexity.
In worst case O( n2 logn ) is time complexity.
b.
Yes the Time complextity of Dijkstra's algorithm depends upon whether Adjacency list or Adjacency matrix is used for representation of graph.
If adjacency list is used then, complextity of Dijkstra's algorithm:
= O(n) + O(n) + O(n logn) + O(e) + O(e logn) = O( n + e logn )
If adjacency matrix is used then, complextity of Dijkstra's algorithm:
= O(n) + O(n) + O(n logn) + O(n2) + O(e logn) = O( n2 + e logn )
REASON:
//See a, b, c, c1, c2, c3 and c4 steps and their complexity in pseudocode above.
(a) Initializing dist and prev vectors with infinity and -1 respectively takes O(n) time.
(b) Building minHeap (say Q) takes O(n) time
(c) while loop runs for n iterations means O(n) time.
(c1) Inside while a vertex (say u) is deleted which takes O(log n) time, then for n iterations of while loop total complexity is O(n) * O(log n) = O(n log n)
(c2) Inside while, finding adjacent of deleted vertex u, taked O(deg(u)) in adjacency list but it takes O(n) in adjacency matrix. Here is the difference in their complexity.
(c3) For loop runs for deg(u) iterations and it contains key decrement function (c4 step) which requires O(log n). So in total keyDecrement in for loop which is inside while loop, total becomes = log n * deg (u) * n = O(e * log n)
In this way, adj list takes O(n) + O(n) + O(n logn) + O(e) + O(e logn) = O( n + e logn ) in total.
Whereas adj list takes O(n) + O(n) + O(n logn) + O(n2) + O(e logn) = O( n2 + e logn ) in total.
Best case is sparse (e = n) and worst is dense (e = n2).
Adj list, best case = O(n logn), worst case = O(n2 logn)
Adj matrix, best case = O(n2), worst case = O(n2 logn)
For Dijkstra’s shortest path algorithm: a. Give the Big-O time for Dijkstra’s shortest path algorithm and...
For Dijkstra’s shortest path algorithm: a. Give the Big-O time for Dijkstra’s shortest path algorithm and explain your answer. b. Does the answer to (a) depend on whether we use an adjacency matrix or list? Explain your answer.
PYTHON ONLY Implement the Dijkstra’s Shortest path algorithm in Python. A graph with 10 nodes (Node 0 to node 9) must be implemented. You are supposed to denote the distance of the edges via an adjacency matrix (You can assume the edge weights are either 0 or a positive value). The adjacency matrix is supposed to be a 2-D array and it is to be inputted to the graph. Remember that the adjacency list denotes the edge values for the...
Dijkstra’s Algorithm: You have to implement the Dijkstra’s
algorithm and apply it on the graph provided below.
You have to take the input from the user as an adjacency matrix
representing the graph, the source, the destination. Then you have
to apply the Dijkstra’s algorithm to find the shortest path from
the source and the destination, and find the shortest
route between the source and the destination.
For the input you have to read it from a file. It will...
Use Dijkstra’s Shortest Path Algorithm
Example 2- A is the initial vertex: 9 6 2
In the shortest path routing, what affects its cost? What is unique about Dijkstra’s Algorithm?
For each of the following, give the Big-O time and explain your answer: a. Breadth-first search/traversal using an adjacency matrix. b. Breadth-first search/traversal using an adjacency list. c. Depth-first search/traversal using an adjacency matrix. d. Depth-first search/traversal using an adjacency list.
Implement Dijkstra's algorithm to find the shortest path from vertex O to all other vertices in the graph below. Use the adjacency list representation to store and use the graph in memory. Do not use any other representation Use vertex 'A' as your source vertex (begin the algorithm from A). Your output should be of the following format with the second column filled out. The distance from the source vertex (second column) is the sum of weights on the shortest...
Use Dijkstra’s algorithm to find the shortest path from a to z.
In each case make tables similar to Table 10.7.1 to show the action
of the algorithm.
15. The graph of exercise 9 (shown
above) with a = a and z = f
Note: Please include the table similar to the following format
in the answer.
11 |10 f 12--- C0 0d C1 7/ 7-1 2 all-4 4 |を 35 3 a 4 9
Design and implement Dijkstra’s algorithm to
compute all-pair shortest paths in any given graph using
An adjacency matrix using a one-dimensional array for
storing only the elements of the lower triangle in the adjacency
matrix.[Program in C language]
The input to program must be connected, undirected, and weighted
graphs. The programs must be able to find shortest paths on two
types of connected, undirected, and weighted graphs: complete graph
(a graph with a link between every pair of nodes) and...
Consider the following network.
a. (16 pt.)
With the indicated link costs, use Dijkstra’s shortest-path
algorithm to compute the shortest path from “w” to
all network nodes. Show how the algorithm works by computing the
table below. Note: If there exists any tie in each step, choose the
left-most column first.
Step
N’
D(s),
p(s)
D(t),
p(t)
D(u),
p(u)
D(v),
p(v)
D(x),
p(x)
D(y),
p(y)
D(z),
p(z)
0
1
2
3
4
5
6
7
b. (7 pt.)
Construct the...