0% found this document useful (0 votes)
18 views8 pages

DAA Assignment 3

This document describes the Prim's algorithm for finding the minimum spanning tree of a connected weighted graph. It explains how the algorithm works by selecting the edge with the lowest weight that connects to an unprocessed vertex at each step, and includes an example of applying the algorithm to find the shortest path from a single source vertex.

Uploaded by

pandeychhotu81
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)
18 views8 pages

DAA Assignment 3

This document describes the Prim's algorithm for finding the minimum spanning tree of a connected weighted graph. It explains how the algorithm works by selecting the edge with the lowest weight that connects to an unprocessed vertex at each step, and includes an example of applying the algorithm to find the shortest path from a single source vertex.

Uploaded by

pandeychhotu81
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

Yadav Co) DAA Pssignmunt-3

vias |Cumar 240786|SOUE

tree
DeAne minimum spannng
genes t e
algoith m to

4enerate HIT
ocight

tthe fo lloning

Hiaimn Sparrirg Trre

wesghtes graph ree that

Jhe the
he verhces

posrible to tel edge


minimum

Pim alyo thn methec

HIT.

Pim agorith

qn vertea the
2 hith Jhe tmaller weight
Seleco he eaye
Conrett a
the to verten

6wtticle the

edg e he Con necheo!


3 the seleteol

veYles to

4. qn verh°ces are
step

?acluo e

|2

solutton
Explan Pgoithm folvo single toyre

(hoes puth problem wih eeam ple .

Ons 2 lg oñsh m we to Hhe

shoter path Arom single Souree vertey

verice weighteal
graph non ngahve eolge weighls

Here by Step erplanam


clg onthm

Fnisal2akton
a olistanee value ho eeny

Vertea the dl ttance

the kourte o hen

verPces infiy.
Set erg veh
choose the ith the

mim ¯ae from the

Verhee noh Procet eal

fource seleteal.

3. pute dlyance
Selecteol
vetea updute he
diskence v clue of atfacen verKces by aslding
lehve en selee ses
he eslye
vetes astfacent Ukce.
CurenL
Small r
he c sence

Sttane, pelate .
atign eod
vertee Processeol
Marte
Harle Jhe selecseo verten
precessea Cvisfteo!

S. Repeat
sep 2-y ueres
Repead
he deyirekom veren reschest .
procen

selees A (o)

(electC
Conol ho
lgorikm
the miimu ipaning Tree
uitale &ample .

dlgothm greecly agoithm


mim sponning
6f Comneceal (anel'reeted

PBgoihm

(a) the low


eolge
ho high
by tete edge the lo wert

height qnot adol to


ipannirg
bree the esre to

ireates y de hen

Conbnue ho adal eolge we

reeh vevscer 9 Srunning


hee

Be DE

2
4. n 4na pacihy ea
Jenapraclcc
value qn
iemt
foun progaming
he
greealy llem pr saC(k Cnep
tslve knapsaek
the what
3
An considor hoh
CVeate
2
2
( (A)
3 2
DE Elge
oden asCendi
ng Jlep2
knap sace problem Clatic ophmiokor
problem ohere goal ho selees

jtems from eah weight


Qnol vCly e ho mrinLe toas vewe

given Caypatity

The knap soee- pvollem tpeih'uty deals

wih
slecan rejekny meníng yoy

feake Bacton flem.

To ol (Cnap sach prob/em

qrety yerech qn he geeoty


Cheice selekng jtem tha

vaye toi wight. Here the

lep by poluhon given eranpte

Tlemt
vae

THem 2 ! ee 30

Pem 3! alye z 45

len ap sacle capasity 6.

Cod ulete vaye ho oedgh Yaio

(tem
(4
ftem 2
3tem 3
ikem y 2 2

2 Sort basel he vale to weight Jatfo

fn d eseeno'ng Srelr

order > em l, jtem 2, ite m3,

4reeely
Select lem n order
Aull
peld fhem Cwergh! 3 value! ys)

elo

Remeing
Rest!

(eleeto Per tem qud ften

To tuy

Totul

cfprach may hot aaye prou'de Cqn

opima gol uhon Knapa


moblem, depends he

Phytance proltem. Dynam c h

speiht jhstane e puollem Dyne mic

pre jrammig algorithrs C


smmsnly
9 u4yaneee ophmat ntet

You might also like