DSA notes (1)
DSA notes (1)
Step 2: Usig
Using f Statemenf; check tf as b
and asc. Tf tie tondiion ü
(ree Ren 'a' & greakoat.
greatesh
Step 3: T and
b>a and b>c m
means,
b ü greatest . Ofheiuise çgreatesk.
Step 4! Pint the 1eateg t number,
end.
Recursive fnction
toid nain
begin -fact (n)
end
int rec - fact Cn)
begin
teCn-c)
yetge
Fbonacci Series:
Tteyakve.
Procedure Frbonacei (h)
begin 8
aYr [n3; 2 3
Rcie 2; i<sn;lt4)
rn,o icn;it+)
Print arrCiJ
End
Rec ursive Funcion,
void main t)
begin t/w
perfmonce
ioOutpuomponen
"Thput
code.conbtant
Cnt s=0
6rli O, i<n; it4)
S st arr CiJ;
8eturn s;
3
Vorjables
n, s, i, arrCnI
t6e aboue Cocle Aives nt Space
n+n 2
3n +4
te
AddiHon 2 marices:
VOid main )
m=2, n2)
add Cm CHY;
Matrix Addihon:
void mat add (int mCJC27, Tni m2[J23. tow, coli)
chat
S. name ...
Exa mple:
8bruct Stuclent sfuCuI;
int i;
for (ie 0; i<4s, itt )
Scanf("d c c "eSta CiJ.no,
AtADS. name, &stdCrgralt
Sbucture înside a Sbucture!
Struct Student f Sthuct addr d
int n0; chay dno C63;
chay nomeC303; chay Street Cto;
hor rade C33, char city Cicd;
Struct addy adr;
int pin 3;
6 e a m p l e .
Sruct Sbudent
int no;
Char name CtsJ;
char Street[to3;
har
pin;
When
vhs Ihe,memo'd wiu be created ony
Sbructure .
we reate the ohjech or
Poirtevs în structure! sSruct) Shdent sp = S):
Shuct Studtent S;>Siqle dyee
stnuct Student Std Cys];> Anay of oJecra
for Cint izo, iz4s;it+).it.)qm)
Si. gra de A')toist
oiable
dlructure pointer
Sptr +i ’rade;
ite a C
pnogram b maintain a Sbucent
hade 'A
b 'coimbaore'.
and Budent whol not
beiag'"y
Struct Shudent)
int no;
char name [ 20];
har grade C33;
(Stract Addr
char dho [s];
Char sheet CisJ:ersat rods
har ciy C2ol; i shrR
int pîn ;
I4r;)x char cibye3;,,
;
fnt ;
primf("Enter Student detaíls :";
Stuct Shuslent StuCy6J;
26)
ACx) 23245
+5
Strucl term
-6
int Coeffent;
ezpon ent
téiable4
term
Shuct potyromdal ACws,
Shuc term B Cio3;
int t, t2, t ;
2 Poynormi tompieu
Procecdure Adpoy
Sbruel term pagnomia)
int n, n
BaRRY>int tao,.9, k=o;
while (2en e e em)
Tf(ACiJ, exp = SCj3. ero )
c[kI. esco ACrJ,ee;
Co eff;
cCK3. coeff - AC. coeff +BC
ooelae ie ACiJ. exp 8c[1.exp )
C[k3. exp : A13:xp;ih
CCkI. coeff ACi3. toeff;
End while.
While (
Ck]- Coept AciJ. Coefp
=it, k k+)
end
White Ciemn )
t, k -k1;
end,
Assi
Develep
matPd
s]1oSparse matrix:
arix A atrie B
col
8 3
Sparse a v : Representaton
birolal slisl4
arix A sVALI5,5, s7
|o, o, 4]
Row 2]
Co| 2 2 3 |Co, 3, 1]
3
alue. 2
L
a o o l C , 3. 3
marix B.
Row
Lo. 2, J
2 3
Cot Co, 3, 3]
3
2 lc', 2, 2]
Malue
Poceclure ado'Hon (Suet SMQt AT I, BCIe
Sructadd
înt 0w
int val;
Assignment
Add'ion
Sparsenah
Inoertio n:
S = "HelloAlor ld len 10
Sava
Inser ton ’ (Si, s1, s)
DP HelloJavator|d
patfern natching:
0+incudé
Vojd maint) f 3 4 6n8i
Char si J= Hellolelod,
char soC): "aa";
int en : Arlen(si)+ Shlen(s2):
char 3 [leny;
fat fndex = S;
element ht
tDa)
element; S[yeorS
biol Main
C)
element Srear=
eor- Yeort +
sCrea; etement ttRont
ese -) font= rf( etse
n-) if(reaY
==
element) (s, d
CS) remave
Front
Rueue: pobie"
(octy)*Z
-a expresbioo daion
cf
rehurn. and cau functon o
Staclk. Application
of
s) Popl elayo
etement) (s, push
)D5uty) 3Empy Boolean
ste
s)Tsfull( Boolean
síze) moe. (3, Stack reate
Dperatna
5 -Stacks: lo/24/ 22)
ADT Queue:
'ot Of element.
Oljeck Ordered
kunchona:
CYeate OueueC , max. size)
Boolean asfull ( max. 8ize )
Boplean
int n, >element
Vofd Addolque, n)
i (font - Tear )
prtnt ("Queue Empy:
5 t6 4
Stack n4 op -1
push(ite m)
iFCbop = n - )
> postfz
ee
abcd/ t bop--1
’ atlbo(c /4)) S[upJ Herm
Pp CAem)
ifCtop=-1)
Ao itemy to oaplat
Stack a
emp
or Cint i= 0 ,ikeop ;i++) ese
printf('l, sliJ);
postfrx evaluaton:
Step 1:
’564 + >293))
SBep 2!
(416)
5 -o-6
Step 3:
’S.6 >(o-64s)
6