Google-Developer-Student-Club-CCOEW / Competitive-Programming-2023-GDSC-CUMMINS-X-GDSC-MMCOE

Welcome to the Hacktoberfest 2023 Competitive-Programming Cohort for Cummins College and MMCOE students! To request issue assignment, create a pull request, providing: 1. Full Name 🧑‍🎓 2.Email 📧 3.College ID (RNO) 🔢 4.Branch of Study.📚 5. Year 📆 .The Cummins College and MMCOE students' PRs will be considered only. Thank you!
9 stars 69 forks source link

Implementing Dijkstra Algorithm #89

Open saakshii12 opened 1 year ago

saakshii12 commented 1 year ago

Write code in the preferred language and attach output with it.

Given a weighted, undirected and connected graph of V vertices and an adjacency list adj where adj[i] is a list of lists containing two integers where the first integer of each list j denotes there is edge between i and j , second integers corresponds to the weight of that edge . You are given the source vertex S and You to Find the shortest distance of all the vertex's from the source vertex S. You have to return a list of integers denoting shortest distance between each node and Source vertex S.

Note: The Graph doesn't contain any negative weight cycle.

Example 1:

Input: V = 2 adj [] = {{{1, 9}}, {{0, 9}}} S = 0 Output: 0 9 Explanation: image The source vertex is 0. Hence, the shortest distance of node 0 is 0 and the shortest distance from node 1 is 9.

Example 2:

Input: V = 3, E = 3 adj = {{{1, 1}, {2, 6}}, {{2, 3}, {0, 1}}, {{1, 3}, {0, 6}}} S = 2 Output: 4 3 0 Explanation: image For nodes 2 to 0, we can follow the path- 2-1-0. This has a distance of 1+3 = 4, whereas the path 2-0 has a distance of 6. So, the Shortest path from 2 to 0 is 4. The shortest distance from 0 to 1 is 1 .

Your Task: You don't need to read input or print anything. Your task is to complete the function dijkstra() which takes the number of vertices V and an adjacency list adj as input parameters and Source vertex S returns a list of integers, where ith integer denotes the shortest distance of the ith node from the Source node. Here adj[i] contains a list of lists containing two integers where the first integer j denotes that there is an edge between i and j and the second integer w denotes that the weight between edge i and j is w.

MOHIT-PANDEY215 commented 1 year ago

Hey @saakshii12 Please assign this issue to me.

Swetathakare commented 11 months ago

Hey I wish to work on this issue .Could you please assign it to me ? Name : Sweta Thakare Department : Computer (2nd year) Roll no :UCE2022654

srushtikage commented 11 months ago

Hello Please assign this issue to me I want to work on it. Srushti Kage UCE2022531 Cummins College of Engineering for Women Second Year