SIKSHA ‘O’ ANUSANDHAN
DEEMED TO BE UNIVERSITY
Admission Batch: Session:2023-24
Laboratory Record
DESIGN OF ALGORITHMS.
(CA2208)
Submitted by
ere ‘Naincy kumari
Registration No.:___2241041071
Branch: ___BCA_
Semester; __arnd= Section. =a
Department of Bachelor of Computer Applications
Faculty of Engineering & Technology (ITER)
Jagamohan Nagar, Jagamara, Bhubaneswar, Odisha - 751030CONTENT
Remarks
Ent out fee levgest
fee in giver arg
i Assignment Name of the Assignment
5 ofe ment
Yrdert an ele MewF Jn o ghre
a onel Weplag alt
Ina arveg
Clemoub tf tbe arrag-
an giver arr cel tcphs
Ld.
Ley ot qveraye opal
nymber preut jutts ver |
wl dn bern»
ee an elem Sie
poi ef IE oat
Assign menit- TIT J2-16
Assignment a Viel taeDepartmentofBachelorofComputer Applications
Faculty of Bachelorof Computer Applications: (ITER)
kumart
Author’d Peano! 22uso4l07)
Program Dexcnibiton! Wore 4c ee rae
Gnsert an eJeqiente lar aeriver arg and
atisplay all hu efemenb of the armed.
He jnclucle < fala: hd
gt maint )
G int Pre ced = h4,213
DP hi, n, Ods , N= 63
PGi Doe ian 5 er)
grr CIDE 415
for(i 20; fern ; jt)
Prd 8 come CDE
Primt£ ("In") 5
Pei enter yes meals be hwenteaham
Goat fad iB pos);
O4++5 i
for€ i =n-s 5 jd=7Os 5 (4)
arr C19 =9re PID)
Barr [poss = 5
Bier aalOn, epe i 4+4)Departmentof Ba tana
- FacaltyofBachelorof Computer ppleedone (TER)
Pritt (OH ob” arr EID):
Point ("J");
Te turn D0;
3
output
Be
eo cee
Cnter yb no, fo be jeetesh ee
ender Yu Posidim fo be jiserted ! y
Pua Sey Bie eSDepartmentof Bachelorof Computer Applications
Faculty of Bachelorof Computer Applications (ITER)
hors Name '— No rncy. Kamar
Author's Regel rio! 22 You) 09)
payee Desers pdion Li rof out yh, forged
obesredt in th given laces nL Program.
qesi= 6 £9, 6,543
oH Wacinele < std/'o-h>
Int maint)
€ ane
ea 29470"
toeteel 1
healed é
ies oo
6
iF( tea (ena)
§ 3
fea C193
'Z
yy
2
s phere vat fal", L);
(rd Te
Pat ee, siti vo vol p)s
vefurn OeDepartmentof BachelorofComputerApplications
Faculty ofBachelorof Computer Applications (ITER)
}®x fethoob Name, tere
Authows Rezol NO! oAyousog)
Program Deacsj prion | ‘Dote# en' element
from an gaven array ‘anol dys play it jn,
G Program.
Be eile 5 Nb ah
inf mance) 5
¢ )
ree v
prt B=Pos Arr CH= $4,2 534, $589
[ut 1, Pas, 492 = 6-
for (12035 faey j+e)
(4ls
arr Li) =
Bee (ep sens (+4)
po wht (fal iy ae
ProieF f ("In");
fad ent Yh. Posjtjon Yo be olehded)
Sean f ("yal") f Pes);
Vt (Pos >n)
‘oid h(" inveathd pds j dina"): a
else
aia Rose peel 5 40)DepartmentofBachelorof Computer Applications
Faculty of Bachelorof Computer Applications (ITER)
ee (i= Bien s
pod (yal ", av Cid):
Path (hae);
yeofurn OF
Bie! ae
7
enter Yn Pos jon fo be delete)
Name:—Nalnoy kumari
Regd. Number:—2241041071_>
puter Applications
Departmentof Bachelor of Com|
‘Applications (ITER)
FacultyofBachelorofComputer:
ines pe DID Alamel (Nainey kama
Authsys ded NO) 22 ¢ 7OU10F)
Prosram Dercripdina: final out average
i '
oF the sabe nunberd preset jo fee given In
an Breer ¢
ae pachaler Sfoliveb >
jud mands
juta Ce] 2G 45281 A SSE
uf |; a4 5
ie
aut Sum 205
(iin ieee
o
Sumz sum t+ ace?
oe sum fo;
2D
Prod ("sam 2 fa", Bam );
Place Vaverpess Hd", aug);
Tettirn 0;DepartmentofBachelorof Computer Applications
Faculty of Bachelorof Computer Applications (ITER)
pth
Sum 215 ONE et he IG OnASS cnr - La
Department of Bachelorof Computer Applications
Faculty of Bachelor of Computer Applications (ITER)
1] * Authors Nome) Nainet Ieumart
Program Description | Write ac Program
for A Implementation of- Stack
ane! defetinn ppenation) wig Sagdeh cas.
( Indextion
se Rolhele < Spel’ hS
+H Jaelude < Spelli'b b>
Ft define mpx 10
Int Stack CmMpxd:
Int foprs
Voie! pusd (int x);
Int Pop 0);
Votel display OF
int main C)
aa ;
int choice, X5
while (wD
F sink Me honse an operations
Prt 's, poad");
Print f (''2. pop”)5
Point U'S. Disblg
Pa
printf U'bnfer yore-chowes: );
Sconk ( Oop sn Scherer );
[aVere i! (err
== gwiteh Ceboree)
cheloro &
Cast 13 en
e, = Foenaadee Yer element Path J
Seank (fal, BP x
E Push (x); “a
=! break > ’ |
Cased: !
xe pop l)3 "i
eae)
Clee red eed 2 idl
a
break 3 5
Cot rae
clisbleg C3
break;
cose 4%
exit (9)3
Peve a :
Post CU" Invel ‘
i ( I ee te choice! wis
; \
return 0: ‘aie
Stack Cteb =x;
=
‘nt por ()
& ie(4eb == -y
€ Pout £ ( prror + Shack undechholl Jp
veturn-L 5
s
vad xe Shack [teh 3
dep -7>
ryeturn Px
2
Void display ¢)
&
If (teb == -1)
Gis= DepartmentofBachelorof Computer Applications
Faculty of Bachelorof Computer Applications (ITER)
Print (8 Yle Ske vo empty! \n)s
veturn 3
3
Pest C" ye Slack ole suse} are: |n")s
fov (itt tops iesos i#-)’
) *
pdt (pd le, Stok CDs
chorse an operation |
1. pust
9. PoP
3, oisbleg
Y. ext
enter your choice 13
he Sack wo empty!
Name:—Nainey kumar z
Regd. Number:—2241041071__Departmentof BachelorofComputer Applications
Faculty of Bachelorof Computer Applications (ITER)
* Renee Description - Orite a C Program
for Cireular Arovep imPlemenfatien ef que
( inatrtion £ ale le ion) ¥/
+t inchole << Sfoli'd® hS
Hoaefine sizes
int ALCsizeJ=-4;
it yer 2-15
int isemphy 0)
é
i (fore Sos) Be ear =)
veturmn 13
\
else
return 05
3
void engueue Cit Vvotue)
et
H-ergurere (tut water
UF ((vear 41) 7, Size =F trot)
path (Tgueue co fell In)
else
E————
a
Gorrd Oe
pear =(rear tif $122 5
AL vear J= vale 5
Naingy kumar
Nane—_— or
ee
1 Regd. Number:— 2241041071 —= saeee
R
QQ 4
NJ
fr
Nau
DepartmentofBachelorof Computer Applications
Faculty of Bachelorof Computer Applications (ITER)
voi d oleguewe a)
&
1£(tsemplyf))
Pricth(" Quewe is em ply jn
else
if (Prod == vex)
forut = year =713
else
Pyout oC Frat tH) 7 Sizes
3
Void Show front ()
6
14( isemPyl))
pond gueue wo empl} \n HE
OF dh element ot ftront # td" Clad;
2
vord display Quem at)
Pes
if (tsempy o)
print ( " queue us empiy tn")
else
& .
jut 23
j£( Food <2 rear)Departmentof BachelorofComputer Applications
Faculty of Bachelorof Computer Applications (ITER)
=. for( [2 front 3 jenyear $ i++)
Privdt( In fd In", Aciy)
3
else
é
fe Go
while ( I< size)
é ae
wShC pin dn OE
1443
3
Jo 05
ble (ics rer)
&
Petey. fede Acid;
14+
,
,
2)
tnt mara C)
> 4, Value }
re choice , Fla
Dbile ( Flag = =4)
§
Poiatt( "In henguene 2. dequcut 3
Y. ob'splag Bucw -s.enrt In ")
seant (. nds g eboice);
ee Naroy amet — 1 Regd. Number:— 2241041071 ——DepartmentofBachelorof Computer Applications
Faculty of Bachelor of Computer Applications (ITER)
, J
Coser d: pdt ” byder Value pelle
Scant (pal uy gvelee);
Engue- (valve);
break 5
Coat 2: olequew Con
break;
ees Shovtrwt
Case 3: deguers (OE
break;
Case 4? inp lag aueuet):
Dreak ;
Car 5:
flag Oy
break >
3
3
vefurn 0;DepartmentofBachelorof Computer Applications
Faculty of Bachelor of Computer Applications (ITER)
Qu*pes
1. enquenx 9. dequew 3+ Showfrout u. ol 'splag
S. ext}
=
Enter valve |
8D
teenguene 2.de
qe 3 beow-frort u. obi plagsuene
33
1. erguene > galegueus gshpokent 4 displags guewt
8. ent
of
enter volue
‘ uy, abisplagaceut
J. onqurert a dequeut og. shoot ef
S. exitDepartment of Bacheloroft ‘Computer Applications
— Faculty of! BachelorofComputer Applications (ITER)
P RUNDE eumen Callao) a aa fo Creati
va noobs jiven by ple:
He include Seals wh
ae jnchde < Stoll
Struct nod
§
put num }
Gpruct rode ¥ vet Pri
3% Spnoels : ‘
vold Create Nedel's? (utr);
yoial alispleg Cs
fut mam ( )
G
eo; :
Priucbl'” | hinked lish Te coestt an) oipley
Sighy faked Wt .NuLL)
eat ‘Ime mort Com ust be albcated )3
else
food Tobe obata -br vockt 1° ys
Scant ("f.b", frum)
Steele Snumenaum ;
Stnole S nent Pfr = nuets
temp 2 Stnooke 5
tor (1:93 JER jat)
ablrc( sire pfstruct
ae ( strut poole *)
mole’);
14 (foanade i aie)
“ound ("mening panned be allocates "3
break}
ey
eke
Reena Nancy Kimnarl 1 Regd. Number:— 2241041071 —Departmentof Bachelor of Computer Applications
Faculty of Bachelor of Computer Applications (ITER)
Pott " Tufit-otita for uoole +) ar
Seant("/ J uh Bewiea))s
Tape 3 num =
num $
Sn Node > ne wt Pd = LL!
temp ) next phe =faNode?
temp = emp > nextttes
Void ols C )
6
Struct noole Ktmp:
af Stuole ~ = Nut)
§ ”).
Pritt"! fick be en Pt Js
Sedurn $
e
else
6
dtmpe Strocle §
hte (tmp! 2 Nu )
Koti tgche =ol Inj pemP> mee
Samp = tmp > nertPtr 3
3
2
Name:—Nainey kumar
1 Regd. Number:—2241041071 _
Name;—Nainey kumari__
Oe_ out bet
eee ofa! number BF nodes + 5
der tho ete nf of rool 1240
pe etal et wale 9: 20
banter bu ofsbe HE node &; 5%
Jebe op voded ?
Enter
ee babe ip nol $9Departmentof
Faculty of Back
BachelorofComputer Applications
helor of Computer Applications (ITER) As STly NM ENT=3r
OOS earomeas ey CM Oa a AEA roi nimum
olistance of woo numbeyy,
+H inclucle NUM num7)
\£(mindistonce ~— n) ¢
Pos (Vat oy po the Numbers are uot preaout thy
Soper Ja"')s
2 ele g
Port “ remnindmdisteuee ehoesh yell ondep Rien
In", numa, num Cminaistuce );
wrimimum disterce bedoeen 2 and S wo:Department of Bachelorof Computer Applications
Faculty ofBachelorof Computer Applications (ITER)
v jud out ged of to
wg -enehil 4 alloys ton J middle Sebel
number 1,5}
Procedure
eae Males < stdin ks
it ordi 1D Cinta tb) ¢
wht]e (b} =0) &
int -femp =b3
buay,b;
O=femp 5
3
vetum 9;
Oy tuldlescher! trem (isha nenene
while (a) =b)%
if (asp ye
a- =b>
3 else.
be =:
epeturnas
jet maw 0) G ma
“yuck num. , num 25 ane
Pe at
" 4
Scant ("fal spd , Brums fnuma) 5 :
as a nae = entelid tres i
Pout t ( "ben von cslisln Migoor! m fral dw
euclidly Rent);
Naincy kumari
Name:
1 Regd. Number:—2241041071_ __Department of Bachelorof Computer Applications
Faculty of Bachelorof Computer Applications (ITER)
ih maddde-cc hood Road} omiodlle echooll (nes {entra AO
middle se hool Result);
west QO;
3
det bo
grier 100 “4
Lic» wig buslid 0 bya luvs 1g
licp wie riddle cclool Procedure . 4
mber . 4 4DepartmentofBachelorot
Faculty of}
Computer Applications
Bachelorof Computer Applications (ITER)
UH pliicat on «
EHS jmclushem Staliow as
WF main ¢)
C of A ETL], mot OL20049, mt R 029 £49;
let om 4
it hy 5, 3 ae ix BP oes
Pott (eee oleae of Ye nah nhs
2x9 \n");
-for(fao; f<2: i 44)
6 .
cher (52055 <35 544)
§
Seant ("fd", J mot PCIILII)s
Ys 9
Lhe Second) matrix of-
Pr AL ( tt opter clement of +
oder any Ja");
fer (i=o: <3 5 fas)
>
hor (S20; Jey sJt4)
f a +.
Seank ( oh) _ f mad OC ICSD;
4
3 ;
for (i0; 22; j4¥)
Naincy kumari 1
Name:—“Stoy kumar)
Regd. Number; 2241041071Departmentof BachelorofComputerApplications
Faculty of Bachelorof Computer Applications (ITER)
¢
fer (jd 3J
ay inch multiplag rrumberd Cischn ys
fut main’):
; Ss
=p int" ler a Positive incheger 3
Scan¥ ( pol”, gn);
Poi tf a Ce ae ay, # = ol u) 3
woe}? Py mumbers (n));
weturn DS
Fe)
loge tu mult plagrlumber (it n) ‘
1£ (n a)
rreturn n* rouwltiply Number (a)
else
esti 13
OE mn
= Euter Positive
fretorial te 4. oy
i
\\
nthegor :yDepartmentof Bachelorof Computer Applications
Faculty of Bachelorof Computer Applications (ITER)
[RED TIE 0 Program Fo fetiue
3 ,
it main ( )
fp main (. D)
@
oie ja ve
fh k ; er
aes beanie ao
Geqguence :? y)
Nain ‘kumari 1
—————Nainey kumari_
Regd. Number:—2241041071_—Vepartmentorbachelor of Computer Applications
Faculty of BachelorofComputer Applications (ITER)
b arr Ci])3
Scant (e hea)
: aes
ponstt ( eater fe key eh Jemech ¢o Sex claagm
Seanf (“ ian I key )s
ji posidion = inex See, (arr jn. keg)3
if ( posifion 1 = -1)
Kea 5 Position +1)3
aa
a hate James al vat found tm he Seynente
i‘ "keg )3
pe abs
3 ee ae a
j ty in aa te
a
sani > num ber of @
ae se erect PS aa
sep eeey eM L
eke Yo Search:
én de al ve
GSeguent€ »
ieee es tot: ‘ip siver| ta ye v
‘Name:——Naincy kumar eee
4 sition id
‘ port f ( Semen ‘dol Hod at: posit! +) }Department of Computer Science & Engineering SstiNMeENT— Jv =
Faculty of Engineering & Technology (ITER) _AsstunmenT — Ie
Kwelte aq Program Sort = aig
af sles cenctiog ordey by usieg Selectin Sort (by using
00 funch'nd)* *7
= Prcfucle < steliovh®
Voie) Soop tit *xP> cb typ JG
heh temp = XPS
SKE ys
x yp atemey
order Cink awe 0, wn) G
~ i.
Void -Selectiea Sort ireendivgy:
ARR EArie vik 5
for (SEO3 KN SS 14)
amine idx = 85
for (i= fad 5 den3 Ia
if (arr elec Sila
ide)
te heals a
ooh (Rave Commie I, fas (12);
3
i)
; i : atin
void Gchection sort De acending order(nd arta” g
pot G3) meme iales
Ftor( §20sien-4; iH
max—idx > O35
tow fl jotes pdzn3i+4)
16 (arr LID > are Cmax — 13)
Pee at = 5 ;
Swab (farrDmarida, pave esDepartment of Computer Science & Engineering
Faculty of Engineering & Technology (ITER)
Wk maint )
€
WH arr EDs € 64) os NO LL
luck yn = ola. cnp (a7) [size th Carr Col);
Pritt ("" ovigined errr );
for (a 1=0512n3 jas)
pend (fad, arrtid 5;
Sclection Sort fascending order (arv,n)s
Pant f (" \n Flrraas Sorted iu agcendi order NF
For fai 103 1293 144)”
pond y1", acid)
. ar).
Selection sort des ending ober We ;
Po ct f('"|n fread, Sorted'in De condi ole ')
for (it J=0;1en; i++)
Pouch (thal) a> cid) y
sedurn 05
0 rs original arred : GY 2S 12 22M
Arve Sorted in agenclirg ordey ai 1% 222S/euDepartment of Computer Science & Engineering
Faculty of Engineering & Technology (ITER)
H.vwrvile a Program fo Sort
Sort. O Ageensding order (3) Descending order.
at inchachteg < Sfoli'» h>
Volo Swap Cit ¥xp,iut *yp JE
it temp = *xp 5
e XPS Kp;
¥ yp > temP;
eS
void bubble sort Agcenshing (nhc sntn) €
fee
for isd icn—13 i+#
or ( j= Dei eteethae
if [ar eda ary Cit)
Swab Cf arr l39 fareli#t ys
8
void bubble soot Desenshivg C
(ano
for (205 jen-L3 i++)
or(j=03 jen-i yt)
if (arrli} )
tet arryCI=€ou, 95512, 22 ee
tub n= sizeop (arr) / sizeof (arr fons
Poi dt ("original wwrey.")5
or (it F205 eng 144)
Paid FUN | ne eons)
bubble Sort fiseendi order (arv> )3
Pritt ("Kn Avr} Sorted Iw ogcend iva order’);
ae (ities tens 143)
Pod (" fod arr cia);
Bubble Sovt Degenslig prdey (oer 7);
Pod Un Prva Sorted 1” Oesedig paler
Per Lor( fetes fen 14)
Pant (Syd, 77 cid);
cgeturn 03
3 eee
outpet Owigned Corea by 26 12 22 NI
Pome Bortedl in Be cording Order! V1 Betis
2s 64
overs sorted 19 Des cosh Order | 4 2S
2.2. SlDepartment of Computer Science & Engineering
Faculty of Engineering & Technology (ITER)
Kawsite a Program to impleme brut force.
approach 2, Sequential 8 ring mot ehing 4
He ineduole 2 Sfolip-hs
He include 2 Stig “hd
Mut maint) &
Char fext £I= es
char pattern [ I=" nan Me
jut fertdeng tt = strlen (tet);
jut Pattern beng = SYolen ( pattern)s
for Lit 12 Os hc text Leng HA a patternlengt 5
int vated Sry
ot pivei gs pee farttern § iene
1£( dere Cis! = Pern CID) E
Paes =05
break }
3}
P a
news vs Ye i ,
jaye
2
if [mete Ng
prime PAP” ie
4
ah inslextfalaae
(lie 3 JP ps al
meter D3Department of Computer Science & Engineering
Faculty of Engineering & Technology (ITER)
KUWOrMI fe Program te implement BO Maye Sort 4
AP inchiobe < Stoloehs
4t inclede < Stdlihehs
Void mevge Ct avr £7; jut 1, tm, ite,
aes
lt £5, KS
iat Ale ae lta
nt n2 > MS
int L Emi, RCOw]
Gor (d= 05 de may a4y
LUJ sc atissds
for (5205 Jere 5 549)
Qcid=arrtm 4443
y
pie Oh.
kr15
while (dens Be i209) &
ie(Lcia<=pcsde
ase K1 2b £13
t5
BB.
Clse €
avs CK1= R054>
Sat
ee
K+t5
2a \ 4
Bes Ll
TAM \ "SD iy! ie
3
Department of Computer Science & Engineering
Faculty of Engineering & Technology (ITER)
while (a2 mide
QE Ko =P cid)
aa
KAA;
3
while Fine Jé
ary CE1= ROI
Jx45
ett
2
2
' : Pic
or merge soxt Cot Te cae t 2
fla 29) %
\wh m= rates) fs
mn exge sort tary], m);
ort ( arr ,m41>7%)5
merges
1, ™m¥)5
m eorgessort Carr,
2)
void priet frre (dt ACF
c ack Bs
\ >
JS 0; K Se 5 si)
Ot acids
Print Cn);
g
sit Gye.)
NA ra Regd. Number:—————____:
pcb main v)
Vit asx EI et y2 I) 13)
Vide orrcize = S122P ay (avr) / si
Paictt (given sored is w)s
Pr'sch Povey ory p.0eeTS
; mergesort Carr 10, arr -SIt
Pott es a Soacted array. i) 1
Potiact Prrvag (avy, ary. Size),
return 0;
2
Pon
biveY arred Br :
na {Wl NS
Boyles) ear. vot
eve cia yo 13Department of Computer Science & Engineering at
Faculty of Engineering & Technology (ITER)
[¥s.tonp Jo mplement Quick Sort here
last clement had +faken 0 pivt-
At inchole ~stdio-hd
Void Cuda p Ciut ta, jh) €
tut 42> *a;
*a = *b;
Bab ets
=
ick partition (rk one CA.if, tow nchigh)e
it pivot = arrC hight;
Vat Ga ( low -1)5
for (int jlo des Wish 15 5446
If Conf jd < pivot) é
\4+5
Boat tf avr Lid ZarelS))3
oop ( porr Ci43d, B arr Wgh});
Seturn (4 yp
o
Void qpicksort ut are lD yiut loo, ju high) €
If (How < high) €
iu pic patition Care, low, high)sDepartment of Computer Science & Engineering
Faculty of Engineering & Technology (ITER)
3
ind main ©)
é
jctar CAs Ete, 11, 18,55 6 5
Int n= S128 Of- (avy) /sizeot( arto);
Pet (heen Gea
fr (it fo; Jen 5 jt)
Pritt ("fdl" orrci3)s
puicksort Carr, Des):
Pritt" Sorfeal array In"),
a er pAde OP jan 5 j++)
Priutf (| ") rr Cid);
welum 0:
Liven are ws!
1 i Ves tie
Sorted orrved, wy
Rea eae
Name:————-———————- Regd. Number:—————————