0% found this document useful (0 votes)
13 views

Daa Lab Evaluation

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)
13 views

Daa Lab Evaluation

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
You are on page 1/ 10

Dan eb Eya-1

Taam embeul
y a d a Vankata sa Kth CB.N0cte 20of,

Pouvada sai Kivan cR.sN-9E 206 2


PA uru Dav eB.EN 9C 20023
M.S Vinenh c . N. O4CSE 003

uestion 1
At CoMpan nemed PT 4 T ha a netuooru n tatfons
Conecte d high Spetd (ommunl catton , (nrs Eash
Cutomevs phone iconnecte d to one ttatton. In his

Or he ana
SngineA% RTT have developed a
pototyp a ideophone SATemThat allos two eutoneny

Seeeach, 6Th e durina a phone ca oY r t mu


to
it 7eae h uain
The st of stetions an
quaity
no mor thon inks.

4 Solutionl
tatione That ies wThin 4 odQe
Heve We need to tind

patht e inKS thin

Can wing depth. tvaues a. CFS).


fovfov Thi
we

whlch au Connectec
Becaure we have nperlins
to
Stations we e Can deine me Thod t e t
by
all taion) nearb lints uTh in a d u q
print
at erhices and
s fAs we an doines a r loop o
anoThey m nad
h l l and Then
catls
victed to
dtet
attun set.

is a ecaYsve alonTh M. baqad en


.AsTh' sets

duth.-tut seaveh ushve we apt inkstor a pori cula


KTehi on wiThin Th 2adius 9:Then w
to n eat
and 1Y0tee d
t Aaonswrhio adu
teion
t

Pse udocods
AHgorithm ttSet lG):
S7tushon
(VE) 1epresenting
nput 9rph G
Set of
SteHons .
Outtput:

cafov in

Steons Acceb l e t v o m
PrinE"
Stetion 1-hum, "ane: "

neturnsett (G,1,6,Visited).

etu rnets (V, dpTh)


put 4 d CVertex 4 dapTw)

Ve rtices
Output 7 Set

pint CV)

fov

etun Sett (i, d+)

Tme Comple
me
Search. travey
tnow. for dejthint
As uwe

is O CV+E).
COmplex y
epeat This proce
fov au terion4

we
haveto
nd

hme.
The
ime comple is o ( * (vtEJ -tov Te
ve-for,
Theve-fo

npatTh m
The time delaa a
br ftance. cau can be date vmine-
2
bby muiplying a Sma xedConeten t by t numEbe
communi on. Unk on the
etkphone. netuwoYk.
between. Calle and Cate uppe e The teephone neoo

ot a compan
Lompany. nanad Rr4 T is afree tree. th engine
PT 4T wans to Com pudeth merImum Dotuble.-
Gvean icient al çorThm and implament: fov.

Computing d emetey otT


Soluton
TheThe dlamet c aree is he ditan e r o m h a

Centy e The tye. theye a Posible chntu

Tree with. inle .Cetey v ree uith Cenru

oY. ree otn one Centve 2 fs the diemete

AWnC 2H Otuawîe

s we emoVi ng
h le at nod.

O he ree
t
unt hos erha o 2 nod

hudoco del
C LOunl
AloaTthm

aut demeter (T):

no-nodu CT) z 2l

Aeurn

n0nodes CTD:#2

Neturn c +

tor 1n T nodes
f i leat

damts (T ct)
34 TMximum pa nning Tree can b found H n n alyo

but wttn e i t modi cation.

EX

chooting au yoot node hoow ngc etex a nok.

OLrtex a node
Nou chooting

v2vtex au n o
Now chooun2

ayimum Cpannlng tve


weivt
Th tot ed

f 23

Mu do coe may &panning I7 ( G):


J p e l ent SCen=
+he raph
npur C 4) E )
The maximu m DOnning the
Otpu

fos i l fo (vl-1 co.


u)
nd max wesht eaje
omon at edo2y CULI,

ET ET.vCe).
etun ET.

OCv

ime complext
thm BubLle Sort (A,n)
Inpot: aay
to Sor and
leg t
oofput alay
in
Ser trd order
Fo14o
to n-2 do
for to n-2- do
Jo
do
i A] >
Ai+
Swap AC], ^Ci+]
c turn A

Time Complezity
-2 n-2-1
n-
(n-2-) +1

n- -
i-0

(n-1

=oCn)
Sor t (A,):
Algoithm Selec tion
fvay to
be
So ted and engi
npot
in Sor te d Orde y
outpuf : hray

FoT Eo to 7-2 do
Srellii

to n- do
FoT j-í+1
if Sma> S a l CJ do
Smal

Sun p ACG1, A[smallD


cturn A
Time Com pleziy
ID j i t

n-z
n - A

2
n - 1

nn-

oCr)

Aloith In Seion Sort(A,n)


to Sor and ength
npt Array
d order
OutpuF Avay in Sorte

For iEI b n- do .
ji-
cwhile i Zo ond AC] AG] do

Te tuvn A

Time Complexî y d(n*)


etf
)Al8ovthm Meesor (A, x,})
imrot a o y to sot loe and uPre

bound
Outrut Aduy in soxted ord er

mid-at)/2
Mesesoet CA, mià)
Mexdesoxt (A,midt \8)
mere CA mid
3)
AlQoithm mesde CA X mia 3)%

mid 1
adss L A [ l -mid

k x
uhile i mid and 4 3d.
P

ALKabrL
i+

A T-r
k-kt
+
aoiThm Guick sov4
(Aa3)
Pivo -h

whtle i4 do

i AC < Pivot do

if
ACT Pivot do
-t
do
ACi]> Pivot and AC] Pivot
Soa P ACia, aG]
Swa p
AI , AC]
Quitt Sort CA,,).
Suice Sor (A,i4,
Time Complexi k y o (n lo7 n).
GAhC onlaki Sons:

o t nl o a n )

Tnfut s2e
On)
Dubble Sodt,Selectlon
sost, insestien Sert
auick sovti hee Soy

You might also like