0% found this document useful (0 votes)
50 views2 pages

Final Exam

Dijkstra's algorithm finds the shortest paths between vertices in a graph. It works by initially assigning all vertices infinite distances from the source vertex and then iteratively updating distances by exploring adjacent vertices. An example application is routing protocols for routers to update forwarding tables with the shortest cost path between routers. While it is useful for finding shortest paths, disadvantages include high computational costs for large graphs and inability to handle graphs with negative edge weights.

Uploaded by

Neil Marc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Final Exam

Dijkstra's algorithm finds the shortest paths between vertices in a graph. It works by initially assigning all vertices infinite distances from the source vertex and then iteratively updating distances by exploring adjacent vertices. An example application is routing protocols for routers to update forwarding tables with the shortest cost path between routers. While it is useful for finding shortest paths, disadvantages include high computational costs for large graphs and inability to handle graphs with negative edge weights.

Uploaded by

Neil Marc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

NAME: Mae Joy A. Pasquin Yr. & Sec.

: 2nd BSCS

1. What is Dijkstra’s Algorithm?


Answer:
Dijkstra’s algorithm allows us to find the shortest path between any two vertices of a
graph.
It differs from the minimum spanning tree because the shortest distance between two
vertices might not include all the vertices of the graph.

2. How to Implement the Dijkstra’s Algorithm?


Answer:
Dijkstra’s Algorithm works on the basis that any subpath B -> D of the shortest path A -
> D between vertices A and D is also the shortest path between vertices B and D.

Djikstra used this property in the opposite direction i.e we overestimate the distance of
each vertex from the starting vertex. Then we visit each node and its neighbours to find
the shortest subpath to those neighbours.
The algorithm uses a greedy approach in the sense that we find the next best solution
hoping that the end result is the best solution for the whole problem.

3. Working Example of Dijkstra’s Algorithm.


Answer:
Given a graph and a source vertex in the graph, find the shortest paths from the source
to all vertices in the given graph.
Examples:

Input: src = 0, the graph is shown below.

Output: 0 4 12 19 21 11 9 8 14
Explanation: The distance from 0 to 1 = 4.
The minimum distance from 0 to 2 = 12. 0->1->2
The minimum distance from 0 to 3 = 19. 0->1->2->3
The minimum distance from 0 to 4 = 21. 0->7->6->5->4
The minimum distance from 0 to 5 = 11. 0->7->6->5
The minimum distance from 0 to 6 = 9. 0->7->6
The minimum distance from 0 to 7 = 8. 0->7
The minimum distance from 0 to 8 = 14. 0->1->2->8
4. Applications of Dijkstra’s Algorithm.
Answer:
Dijkstra’s algorithm is widely used in the routing protocols required by the routers to
update their forwarding table. The algorithm provides the shortest cost path from the
source router to other routers in the network.

5. Advantages and Disadvantages of Dijkstra’s Algorithm.


Answer:
Advantages of Dijkstra’s Algorithm
It is employed to identify the shortest path. It is very popular in the Geographical Maps.
It is used to locate the points on the map that correspond to the graph’s vertices. In
order to identify the Open Shortest Path First, it is needed in IP routing.
The major disadvantage of the algorithm is the fact that it does a blind search there by
consuming a lot of time waste of necessary resources. Another disadvantage is that it
cannot handle negative edges. This leads to acyclic graphs and most often cannot obtain
the right shortest path.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy