MODULE | DATA STRUCTURE AND ANALYSIS OF ALGORITHM
Trees and Graphs
Intermediate to Advanced
Practice Assignment
120 min
This Intermediate to Advanced case study helps you apply your knowledge and skills
of Trees and Graphs to solve the problems of a real-life scenario.
Practice Assignment II
Graph Implementation with Dijkstra's Algorithm
Problem Description
A software application needs a system to manage a graph and find the
shortest path using Dijkstra's algorithm. This case study outlines a
structured approach for developing a simple Graph Implementation with
Dijkstra's Algorithm.
This material is owned by Tata Consultancy Services Limited. Unauthorized duplication,
reproduction, downloading, or screen capturing is strictly forbidden and may result in legal 1
action, unless you obtain TCS's written permission. Using our Services does not give you
ownership of any intellectual property rights in our Services or the content you access.
MODULE | DATA STRUCTURE AND ANALYSIS OF ALGORITHM
Trees and Graphs
Tasks
1. Graph Management
Create a class to represent a graph. Each graph should support the
following operations:
• Add Vertex (add a vertex to the graph)
• Add Edge (add an edge between two vertices with a weight)
• Display (display the graph)
2. Shortest Path Calculation
Implement Dijkstra's algorithm to find the shortest path from a source
vertex to all other vertices.
Hints
ü Use a class to represent the graph.
ü Implement methods to add vertices and edges, and display the
graph.
ü Implement Dijkstra's algorithm to find the shortest path.
ü Test the system by adding vertices and edges, displaying the graph,
and finding the shortest path using Dijkstra's algorithm.
Unauthorized duplication, reproduction, downloading, or screen capturing is strictly 2
forbidden and may result in legal action.