Professional Documents
Culture Documents
Page No.
EXPERI HEMT
Aitw
rmptemeht S e-tLetiOtusore Bu-bb(e Sore, -Tr,sertion sore,
sere, CLUiCFv Herge-
Heap gore qhh0W a-L cc data— Stru-ctU>-L
S o cot-ce code
// Sore
# include iosereatYL>
usinæ namespace std
void se.UoEionSore Cine h) C
For ( inc co
0
=1
For C J++)
(qrrcjJ < Qrr c m'ih-jdxJ)
min —jdx 9
ihE main C) C
ALGORITHH FOR SELECT10N SORT
Set MIN to
lìsf:
SHQp AH}) v a.bz
Zncrernerrt— n /M 'to cterneh-t-
S Repeo-t On•til i.8
Date
Page No.
IhE = 3, 1,2, +22 J ;
ìnE n = sizeoç (Qhh)/ s)zeoÊ
(qrhC02),
re±ühtv O
// BUûBLE SORT
ÌhcLude
usine- name-cpacesel >
f-Oh C J =O ;
( QrrCìJ > Qht-Cj+lJ ,
L t-7 lìsf=
lìs{ cì+1D
end
ehd Soh
end.
Dote
Page No.
ine main C
ine qrrCJ= l, g, 4, 2J,
sizeof Carr) sizeotC C QrrCOJ)
bubbleSorb Carr, h)
cowe<< " SortecL Nn
prinE/Qrhqy-Carr,
returrc o
1/ ZNSERTIOM soRT
# include <icstream >
usinth namespece std
while (j qrrCJU2
arrCj+lJ -z qrrCÜJ,
Qhr Key)
ALGORITHn FOR RTION soPT
ìnt- mq)n
ì ne QDhCD 4,23
n = sïzeee ;
Sere (
ìnser+ìen , h) )
c.-cu-E QhhCIY- \ h
return o
// tlERCAE S0RT
# ìhcblde- <ìOGtreorn2
usino- namespace sto ,
ìnE m ÌnE È) {
void- mergeSere—C ine arrCD
;
in-e LLnIj / RC/)2J
HERGE SORT
ALGORITHrl FOR
cc«nł
3
etse
arh Rqp
uhue U) [
uhț,le
Experiment
Dote
Poge No.
い 加0鬯 sc の ( を 4 な コ, ト工
(ユ
な く
の{
ⅲトm = 工子( 一工) / 2
me e50ゎ
去Cqrrt 工ル
mergeScr& ( Qた/ m+1/ r),
merge ( 0の
に/ 工/ m , れ) ・
亡「屮 ( あと0な , と の
v比p た ){ 〔 〕
( と ~ =0丿[ '<のノ早丿
乙 くく 乙くく
0吐ー 〔 〕
こ0 eれ
- (く と
を ル= 5冫 ト) / s /=00 み ( 4 な Co」丿ノ
, eo 戸 ( 0 わ
m erg eso に
く50 たとe 市 q
00ーく たた
Q
4ダ ( 0 ー わノ
p 戸n士れわ
「
eゆ 0 )
Dote
ìnclude <ìosfream>
asìny namespqce sta ;
coue qrrtIJ
ce UE endL
FOR QUICK soRr
return o'
11 HEAP SORT
# include
QSÌn9- marnespace st-ct
HeapSoh+—
euìld max Heqp Cart)
For i ¯ leng+hCory) 2
Skop C
heap —s)zê
Max (Orr, ID
(ctrl o Heap
h eup —size Cam) z lenal})
for I tcnalb (om)/2 1-0
Nax HeapiJt$ (arr, D
Date
Page No.
heQpiA}-Cqrh,
3
F-ch C ine n
swap Cqnt- co] ,qrr ci));
heapify- CQrr o );
For C ìnE
coU± arrri)
11
endi)
tnaih () f-
QthCJ= C5/ 3/1 / g /+,2 J
ì ne
(qrFCOJ))
sizeoF Car» / Sizeof
heapSohE Carr, h )
"axHeapif'8(am/ )
tj8h.Fti)
L ? heap— Size and- CLJ > QrrC?J
targes& L
elSe
largest d
R ? heap-sizeCarra > orr
largese = R
returtu o
Dote
Page No.
EXPERIMENT
Aim
rmplement- the Search in
hashih method
source code
include
# include < StT1h9 , h 7
# include <
# )hcLude < std lib•h2
usiny nQmespczcestd
define -SIZE 20
ine hoshTQb1eCNKIX-SIZEJ)
void Hash T qble ( in& Keg)
int index 1<0.8 rt0(-SlzE ,
C hash Table CihdemJ I
ihd ex Cihdex +1) •Z nAx-sjzE
Date
Page No.
inv maih ( ) {
memseE ( hashTQ6(e , SizeoF ( hqChTable))
For ( i —o to
3
return— o )
Dote
Page No.
EXPERIHENT
Aim
st-rueE C
iht desE
st-rue &Ncde nexe;
J;
Struct
struzt- OstNode he-ox;
Struct— Ctraph— C
int v •
StrucE AdList-e arra%,
J)
Date
Page No.
Strur-E GraphL ct-eate Graph (ìht- V)
Graph Cstru,ce Groph+) tna-UocCsÌzeoÇ
Cstru-cEGraph));
Û hQph V V;
fÒh (int- È
8t-Qp)v
NUL
L)
he+üFtugmph
FOR OFS
DFS C Depth F İnçe Seqrch)
2 :nitiaüze alL node tö hecıd$ sta..ü C
2 Pusb starting hode OhtD STACV changc statü' b
wajtihg- 5tQ.Ü C STAT VS
3. ReperE Step 4 and step 5 UnHL empty
Rop the top Node N Of STACK, N and chany
b The proce&ed C 3)
Pu5h onto Stock ÜL tbe heighbourv$ N thQE UL
ih reod% senle CsTATVS
fbe Wortih9 StQ.f:cC
Qhd chonoe fhLÜv
STATUSz 2)
CEnd step 3 Loop2
ExıE
Dote
Page No.
print-p Cs' 'j)/
visited C 10 = /
queueCreahJ
C re-ah)
ihE CC
= queue CfronE)
printe C
FronE +4
St-race LhsfNcde pCraj•JL= grqph qrhQ/ CuJ. h-ß-ad
C pCrQiJl) C
C pCr-Qi.Jl desfJ = / t/
queue Crear] pCrQwL
rear
ihE main C
add , , 2)
Dote
Page No.
adcLGdffÜCgrapL / 2, o ) /
add Edge C 8rQph 3)
add C 8hqph 3, 3)
return o