DSA Module - 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Syleakc

etsoty
he

Impremaedintbny

aduantqe
Reusoiiy.

Scalai úty.

Single
boue

bweoe
con hq UOs
Consi hn3.

Homoqaol d a Qeree,
conlaht bne

beda ahon

Aemenel
Databye Veei a,le mne ISte]

ky te

ioco addeg

InernRene
odidsen

i) ink
yanboe
vole

tu) int
(6 20
s>) (t+)
3

L3LJ
tnt al-s1

(nt

idawer vsikneemet of e
elone

ind a lo] Site

Scanf ste)

goxci-0 esite,

Pantt (
in
Inserl elenot
a lb], ste,

inse.

Scanf 'AoS)
elye

alrosnum
Sitett
lak o an y
Inset

af Stel:nun,
fox(i=site-, i>:0,
Sitett:

Tine conglexit
SAett
doka Deneuk

oehy elenet
tox (:ros -l.
iecie-.i4)
comexih o()
Size - -

of

fooi o, esite -i, )


Time Congleyy
a(?] =a
Site

in

- 0lßogry
6

b
yae

diderccno)

Stalis
whiica

(Rors) talte lace


U'st is (ale bo ttn

to

botten bottou

Tt llows hot ost (ito) xe.


. t o l . dta uCh
’uing
Stall.

p e e in tacl
ate coeas

Pop(\ yReoe
eleet ay

boton(iserptuy but
hot &eHOue
pihons

Call mgt

Baance oan theses Comeon olen n tet etet, CorQlea

d) ToLue honoi
imglemet tach
Rojhen do condiio
Pop(l

taptt
tortt
bup

he data s inserte Leyohd

disply ("undeo
ele

displayoeato (6)
ataoftor

elle disglayla)
tap-
topnoit eeet

disty undeb)

ele

Aricaion,
Exeaesion eolu aion:

coubihaion

and

Hen dlS,

eoEAions

ate
(eeveae oish
Notahen)
Golloos
x
3^2

\5623

S45
62

Gene
a tayS.
oeiand Stols.

ofet:

scennins,

when eRerand (s
apeing
ue

n e
Refn
gxe celec n he cera
\oer
a k and

e ta

not e p and cUseut

bighe
Statk

Stall

taun ad
tihlite tale.

ogeran

c)

)
V

Popl1 2

PoR

tollouo
bas
|asoúchy se

2) R ’ , o
gOREhx exlxEOAoy conueio

+
K

kL
- 4L-R kLt

ph

kLtMN

Pop()

PoPC)
pushlt}

t,( (>t

t,(^
W

IsL¢mN0P Awv
+

Po p)
L-R

(kUtmNt -0Rnwolv*+e
kLtmw-olv|Tt+T

Psuado Code
Thx to foix ((ex)

while (ISenpy ee Hobisheec(Stop),i1)

S.bp(\

S.RuchlexpRI)
whilellSenpty)
Xeaiug
Roky eveaion:

EUahalegothix (ey)

C6eke a
L
Roc'
Co)

Rothle(R1)

26

i)

Time Conaei:
haue

Salls.
yeultt
Reye

Stak

+,+/|

3
&v
*
t,*(ll4)n

tVuw0k|||4N

tt

Reuee
eiahon

Guaalexklex)

Ckeake

PosERx

(atb) Cat)
e

inhix e{xesion

(e ( Ce()
(ert)

(Cat )+ (e( )
((3
Towe of hano
ndisly
hoe

onby Kne

Rlac Small e d'ss.

the

h t
-
(3
"
Solue

Renon
n3

Soare oe,inaion.

SoUce

Sonce Dsnaion

Soce des hnahon..

ot dis

ele

Tou(a,8 c,n) Ato s


move (
2 (2t(n-)t+2t|

alx

()

24,

iine
Squce conexiy =|0a)
coerits
non-coh53u0s locdon

ota

Rointey

(00
lo3

dera
Psinte (keSoece

hode

int daka,
SE node

(ingly NuL
VS

Hel oo

la

hest
olior (2olia4m
(02

yes

&ando o(n)

oleha
tegirig ol)

oln)
oly no nil na aion.

hode

sedeed node
daa:
BUt

((Hoint oin e

(| 2 i
mecs llo cahon

ne

Cat|nedta
nenexkNUl

hed

Secod node.

flheNUw) het

hed_ne

else
20

200
head
Modihy
healnetne |\oo
\(o|300
e Coud hode
lou 200

elie
200

Iob) |linCaet

whilelheR =o)
tkawere ue
(12
Tavese

node

while (eNuLL)

P dok)
(eenne.

Insehon:
A4
beqinninq

200

Sthuck ode

teo

heol

Soo
hed
I|soo
2) at end

hode

J
than
Uae is uyie

(This
Dode
(15)
SE ut node

tnex

200

Delerion:

200 300

node

fxee (1eon) delee


Stxuct

3130e
200

poion'

Sxee(nek )

hode
had
ele
00

200
henxeu= heosA

elie had

Sut node

daka

SPuek Dode t ha tail


hl=0

. fl
he alneu

elle s\sl2e

tul he nes

neev tail,

Iosenion

toil
2e

(o 20
hed

(liso

tilaex
til

hes
at `andom oshon:

nene enReXk
enet
hed

OeleOn:
tex p faul

ee (em

9t saudon o tio.

Saee (le;

hed

it (hed

bed le ne;

elle

epneKt

Tsawey,

ohile(te he Aheao)
Ihgertion inkel
tl

elle toul

he ne tal hexkIH

he.

¬nig

nenext > tail hext

tarl he ne J3
ne
taul= he.

2O

hew l
oleion.

ten=tale

elveit (nRneten)

F&eel(en

elhe

Fee llen)

elle it ( n ne Aempi)
ele
Lwile Ctek heyl= t als hex)

temp ne K = tone
tal le2

toil
lo 1o

200 300

(em! = 200 300

tal 300
goúbou:
tol net

xeellen)

iç (heo)
head

h e o d e hea

elle
tal [ 2

(9
200 (oo
hes xe feul (Ly
he
hetex he 8)

toil

whele llenp =ta)

RoinsC d e t a )
InsaHon:

Geqniug'.
is (heo)

taul
heodtil neo hal

elle

heodgn

tals net heo

lle

he reu taul

talhe heo
henew beod

200 3 0
Lenpnet
he et

ne
tem nex

Deleio n:

stant
heod

(enphel
ilheode)

pintf("t ii enp)

elet(heex=hed)
Single ede
had l=o

else

heod = heod hex


MOXe han One hode.
hedPxev tol
2S

elye

toil =kaipy
talse hed
tail

see(leE)

ternoexk Aerek

iuee
date cthuhe -’Tie

Enawee (io(eien.

Denueuel deleic barren

Cell ed

3 2 1

(Dcleion)
hndioni
issouls
de weUe ()
Tasl Schedn

hadlin

Qweue tN]
weUe enpy:
ehweue (int w)

Asont

else

-|

Fsont
dawee()

Uhdeou

bhe eneu
xont=-l in Quee
elie

sont 4+

F7ot

FXont

rnatt ( aeel°)
ehaweUe lint )

we uolsea=x

weue is

elie

ean = l x e .N,
wevelxe]=

De aueel)

si-)

UndeMa

ele
wod di sslayi

elee

whilelil= tea)

Dooyle

deleieuaae olloe in
Ihsetor

O¬aweue:

Iaet DEQee

Pxeut.
() nset e e t a
( ush.se
PushFxout

eleneuk
ehns

kehns

wnccio.li.

1nsent kont

ese

weues]-x eueFI-x
elleif (zz)
elie

aweuels]

.uevelden)
deaseefsonS

elieit (--)
ee')
in memoxy

elseit(== N-)
elleit (=o)

elie

elle

You might also like