Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7162619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:45:55+00:00 2026-05-28T13:45:55+00:00

Dijkstra(G,w,s) { ISS(G,s); let S be an empty set let Q be a priority

  • 0
Dijkstra(G,w,s) {
  ISS(G,s);
  let S be an empty set
  let Q be a priority queue, initialized with V[G]
  while Q is not Empty:
       u<-extractMin(Q);
       add u to S
       for each vertex v neighbor of u
             Relax(u,v,w);
}

my question is, why is it important to choose the MINIMUM d[v] of all v in Q in every step of the algorithm in the while loop, whats gonna heppen if we dont choose the minimum?

i mean from the way i see it, all edges (u,v) are gonna get relaxed in a breadth first order(means that if – s->u->v and (s,v) not in E then (s,u) would get relaxed before (u,v)),
so why is it important to choose the minimal d[v] every time?

assume there exists a function extractMaxFiniteD(Q) that returns vertex v such that it has max d[v] that is finite in Q

lets assume we change that line to u<-extractMaxFiniteD(Q); can any one draw me a graph in which the modified alg would fail – or even better – what property of shortest path would get violeted?

I know this question might be pretty hard and abstract, but it would be great if some1 could help me with that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:45:56+00:00Added an answer on May 28, 2026 at 1:45 pm

    example:

    nodes: a,b,c
    edges (and weights): (a,b,1) (a,c,10) (b,c,1)

    try your algorithm on this. you’ll find that the least cost path to c is 10 when its obviously 2.

    when you remove a node from Q you don’t relax it ever again, if you remove a node with maximal cost then you don’t consider less expesive ways to reach that node.

    if you don’t want to select the minimal node from Q then you can’t remove it from Q either, you must keep it in the set so it can be relaxed in future iterations. that’s basically what the bellman-ford algorithm does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dijkstra's algorithm was taught to me was as follows while pqueue is not empty:
In the big picture, I'm trying to implement Dijkstra's algorithm using a priority queue.
I am trying to understand why Dijkstra's algorithm will not work with negative weights.
I have set of nodes and edges and i used Dijkstra's algorithm to find
Dijkstra's Shunting Yard algorithm is used to parse an infix notation and generate RPN
Single Source shortest Path Dijkstra's - directed and undirected - works only for positive
In graph theory, what is the distinction between minimal distance (which Dijkstra's algorithm finds),
I understand what Dijkstra's algorithm is, but I don't understand why it works. When
I am aware that Dijkstra's algorithm can find the minimum distance between two nodes
This is the dijkstra structure i am using :(however the MAXV(which is maximum number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.