0% found this document useful (0 votes)
10 views10 pages

PCC Notes

The document discusses various operations on data structures (DS) including insertion, deletion, searching, and sorting. It explains the characteristics of arrays, stacks, and the concept of recursion, as well as the classification of data structures based on storage and data type. Additionally, it covers algorithms for stack operations and their applications in memory management and recursion.

Uploaded by

2024ce80f
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)
10 views10 pages

PCC Notes

The document discusses various operations on data structures (DS) including insertion, deletion, searching, and sorting. It explains the characteristics of arrays, stacks, and the concept of recursion, as well as the classification of data structures based on storage and data type. Additionally, it covers algorithms for stack operations and their applications in memory management and recursion.

Uploaded by

2024ce80f
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

Ara tn hat

înt arr ln] Dale


Operatioms on DS.

Taosersauctere
Evezy 0S
dato
wi sikng
ltontainsmccnk visiting
ontains aaset
set of data elenentt
each element of ns
ike aay) in ovder to pebtom some specic o
Iike Seaxching o sorting opey?
eq. you necd to' calarlate av masta obtinad by gd
in'dilezent Subjects,ie need to traese
complete aray of anks &caleulote total ur
then, ue ill diide the surn by no. of subjecks
to fnd the
avg.
2) Tnsetion: Tnsertion can be defined a a process ot
adding the elemnenti to the Ds at cy loeatu
H he sie of DS, is n
then we en
data elenent to it
3) Deletisn: The proces§ of oemovng an elennent Aem thee
process o
DS is called doletton e dome at
location onyra
Tf ysu ty to delete an elemeut from the empy Ds
then undelpw OCcw.
ocen
4Seasching: The process of fmding the locaton of
element oithin aa DS is called geanching
Ihoe ae twe algoaithme to penfezm Seahg
Reach
Soatinq The the data in a
Speaihedo
Theention, gelecion Rs bubble SoYt
Fage Ne.
Date

Mongin shen 2list A B ef size nm&o, joned


tpbduce grd list c of size mtn is called oengi
-Array
Ilcpegrem to illustrate element acces
int man

intarr[5S. o, 15,20, 253;


/ Array declarata, jnitalizatu
printi"lenent of ane (2] : 7d" arr[2)

o P: lenentat ar [e|$

Fanerbien Taaves al.


cprgaa ta pafsm tartk openatian
in t min)
int ar5=10,20,20,40, So's
nt i
| moditying elemeut at ndo 2
a -[00:

ofP: lemuh
:O, 2o,
T$40,o
etunt
Page No.
Date

lprimitie
baiic pimaky) int cha,toat do uble
-Non-prioitiye (dexived)
clagsitcaton ot Ds:

Aecorhng of data

Horno qeneous Nen-honoqenesug.


2
According ta Sforaae alla.cation typ- tme
Static
Dynanc
3According to storaqe saquene
Linear Non-inea Y

.According to homogene0 LQ

Nom-homogeneaLsome type of data:


may not e att
Shatic:
ho se size structue in as oc afed
memory loca tion are Axed et compilatton
tme
Page No.
Date

dynamic
Hhose who can exspand &thg al
duig erecution of prognam.
proqa
hereeetated aenmay toeato changei
pointer.
i s den cted a t p, & it points owt
mem ory location of Vagia ble stoed.

inear
All it's data elements fom a Seqeen ce ora

ine aY One by one sequonaialla such a linas


man ner one
Stru otre.
One uway -is to hare linear relotonship betn the oena
by maan of Reouential memory location.
hy
The sheY oy is to have ineay relotionsh
cpcientm hy meane o fo tn tey.
bet the elomenti stabko
eq linked ist
ADT Abstact Data type
Thsse ae tso ay t asking at data type
h Mathematical| logicall thstract type
ATmplamentoion
Deintion ot ADT:
Thue ae the entities that ae deftin oda
ind apeaton but don't have melementation dot
Page No.
Date

HP o illustrate string.
int main ()
aYray of char.
Il Creating
inq array &'. 'e'.'e''k','s '/o 4
Char atr

int;
fori=o; i<o;it+) aeleksJo
print f(^ c"arlit+):.
etn S

op:Geeky

featues
) An aYrau is a lineas DS.
An as y is an eq. ot stetic DS, &o the size of asrQy ts
alasays Hred. ialwaye emein Game atthe run t i t
3 An artay is a hemeaeneo de DS.
4Ttisa finite c&leation of similar data elements
’ Array ue Subscript siqn[J subseripl vasalle
Array s] stanteg it can storeup to eleymenti
Goch tlennt can be acessed thnugh it 's ssmtax number.
Index numbes alDays stet uith zoxo
Tn Clanguage, atnas ane stored mchas anay
that oehardled slkekty ditferont than otheays
tveyy char arauy o Sng hag ul chaacte
las t's agt charaoter hich marks the enel of slmg
Page No.
Date

int arx5=lo, 20, 80,4o,


a(3)

te eagalyaso arr+3 * size of (int)


2o46+ 3* 2=202
* a r =2044 a[3]=4O
* a[3]= 20s2

t RecuYsion:

Reeursion ia function ohich call tself peatel


ja called Yecussive tunction. thi techaique.
knowrn as rtcUrsiom.
Paçe No.
Date

Caccs sfeck tof


pdeleto
9 40
3330 SHack:
2 20
Opertion (ufo
Lastinftrst out
fIfO

Nstack is a linear Ds that follaws LIfO painipl,


prnciple
tin irst ut oheas queue has teod ends
font and oeaY.
2) A stack is a contane in shich insertion& deletion
Lcan be done from one end knoon as top af the
ta stack
3) Stack is qn AD T CAbstact data tygeith
shich meane it can store
faedand capanitytich
elementi of innited size
Opesations on stack :
Pah ( Lthon we insestan element in a stack
then o¡esation is koawn as push. It stack is full taen
Overfoo conditiom occuss
2 PopC- ohen we dalete an elemnt trom stack
the opesation is catled pop
pap Tf
Tf the
the Stack is
stack is empty
meani these is no_elesment insid thig state is
knoton al undonfs.
3 Peak()-It etusns the elament at agiren positiom.
2Count) T retuns the total numbes of elenonts
available in a etack.
position.
51
Changetchangey the
alemne
Display(-it pnts au the elementi a n oslack
Page No.
Date

Slack
450
=2
top = 2 33 4
maxN) 4

Alqoritm or puzth gpezation:

Step l: Before inserinq an element in the stack,


toe check hethey thegtack is fall.
Step2TA e ty to insext element in a stack, & stackt
fulloveYfloco Condition occut.
3: ohon wse iitia lize a gtack e set the value cf top.
as -1to check that stack is empty empty
4The elements oill be insested mntil we each the
aximunm Size of the stcckas top = top+I
CPush 10 push 0)
top= -1 to p o ltp=L top=2

to
Pugh operatiorn

emplypttT=3
Pop Operation

Before daleing aa elenaen rom the gtacks


check wthethe the ahack is empta Stacki
)T we ry teto delet the olement fronm empty
then ndertoo Con dition occw
irst access the elumonthhich i DGunted by
Page No.
Date

gtack
Once the
p
decremented
operatiom
1
is perbned pop-t top is
ack
Pop=0
Popdo

a) Cc)

* Write algorith or push opeva tion.


Begin
2 ittop = N then
prin"overflow &exit)
3.Thetneo item.
4To=Top+1
s Stack rop]-’item
6it.
Tmg cormptex1ty =oo(0)
Alqo for pop operationi
1.Bet
top=
print" onderfew &ent")
2.Set item stack Top
4.Top < Top
5: printdem deleted"
fme comlexity= o)
Appliceicn sf Stack
Recuion: Recwsien means at°nchen is Calling itel
agoin SaAgan o maintain the previcus state
4e
the Cermpiter Creates a system Stack in cohich alt
prcvicus r cords of functicn as maintained
2
2) Des (Deph for seaneh Reseaschu inplenented
that e Stack:
Memey management: The stack manaes mey. The
memet atign in the Seential meno bloke.
Back tracking? TA we haue' to create pat to selve,

You might also like