The Gateway to Computer Science Excellence
+1 vote
75 views
Hello,

I have doubt regarding prims algorithm

1)should we choose the lowest cost edge and then implement algo further?

2)Or we choose any vertex and then lowest cost edge of that vertex?
in DS by (367 points) | 75 views

2 Answers

+1 vote
Best answer
IN PRIMS we can chooses any vertex and find the minimum edge ...in such way we add vertex without forming cycle...at every time we include such edge which has minimum cost among all vertex we choose...and process continue..

SO NO COMPULSION ON CHOOSING VERTEX OR EDGE...

IN KRUSKALS..we must have to chooses such edge which has minimum weight and we have add edges as per increasing order of weight ...

SO IN PRIMS = CHOOSE ANY VERTEX AND FIND ITS MINIMUM EDGE and include that EGDE , VERTEX and continue process...
by Boss (11k points)
selected by
0 votes
in prims algo we always starts with a start vertex then check lowest value edge reachable .
by Active (2.5k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,356 answers
198,482 comments
105,254 users