Professional Documents
Culture Documents
DS Ii Assignment
DS Ii Assignment
n Stsize];
632
632-4
intto P-\
632-u*+
VO1d push t )
632-H+
5
632-u*+5
Size -1)
op = 632-u+5
=
632-u*+S$9
stack ts oves}louo \n");
psin 632-ut+5$+
eturn
print Eden an em
Scan /,d", &stm);
STt+to P ikm;
vo d Pop )
4op*-)
pinte(" statk undnklow")
nLtunn
Dsint4("Deleted im: /d\", s[top--J);
C (A+B*c) * ((D+ E-F) /J))
.a+b)*d+e l tftatd}tc
(+
D ab AB
abt
(+*
abt ABC
*
abt d ABL+
ab+dt
+
ABC *+F
a bt d e
+| abtdte
+5d*C ABC+
ABL +D
abtdte
+C AB+DD
abtdte4 C+
+/t ABL¥+ DE
ab +dee f
+/+ E
hec+DE+
abtceefa
+/(++ abtke f a
B+DETE -
+/C+* abtdtefa
abtdte-fo*+
ABC+ DE +F
OC+DEA F-J
a bt+ dr efa*+/+
abt dfefax+/+c
abtdtefo*+ ItC+| BCDE+f-J
.aot)|a-e* * e A+8 *CC D/E
AB
ab
a bc ++C ABC
ab + + BC
abct ABCD
obctd
abCt+d /e ArBCDE
abettd/ee ABLDEF
By the
deriniton 9 a9uet, wn we add an elemintin Que
ALk pointU is in vwayed by l, wheuos, when we Am
eVR an
ele ment
ABS front pointes incalajd by Bt in inplt m ntaton of
tis m ay cage pApblLm
asflw s
CDnsldee
o perautions pefoamed on aqutu (uith 817E-5) as oltow
X ABctD
AB$C*D-E
1) Tiiatlepi Quu is thone so, 4x ont =0 and La = -1
ABCD-E
ABCD-Ef
odd elemanks to quuk, thL STOte
e the qulu beomes
) When we 5 ou
+ Ps CD-EF/
ABCD-Ef/ oltows wih front =0 and
+/t
B C*D- Efly
+/ )Now Suppose we delete a elumen fom uu then, th State ef the
f cD- Ef/G4 front= and
u betomes as ollouws, with neoh
B CD-EF/4H
BC CIRLULAR QueA
-I
OVeo me Dvawbatk ugin
-/ BCDE 4 t 1s The queae wich wRap aDind thi end the akay he
(30 t= =1&%
sead = =-1) susith (snmlool)
nt Asont--; 0 u is undnttow"':
pi
alge Coon=se) Case '+ setan opl t0p
enqueu Cin m ) The deluHd aanarN Cose : Tetuhn opop2:
vOd poin case : 3efn opl*op
s8% , Rsort3);
=*-1) Case I 1ehuhn opi lop2
fso rt ==-i && ean
s0nt=-1, cose
case : Kehun po(opi0p
sont-0
daut setun o
vean)itEm;
else
to p
or li-0 i< stran Cpostti)) itH)
60
o
D
Cct
ab
C
abc
abl
t/t+ ab-d
Sybo Staes
abt-d+
6
abl-dt
3
abt-dt/
632
ob-dt)
61
abt-dtle
6IS
obt-dt/e
abt-d+lee
obt-d4+ lea- A
abt dt|ea*
abt- d+ |ta-* C
albt-d+ lea-C*
(631-2+l46-* 14)
untion ox Touwen lanoí sote
th funthon o% 3 disks uoth
sto tk taI nee
digon
Void towesit n, cho%
b
ATsJ,har B[5, chor c[
tuun
TO (n-1, A»c, B)
Print S*S\+", A, c)
38
TOw(n-l B, t> C),
6 5\-u*2 3 +4
ogosm ovhe epresOn
ate
Smbol
Stack
void moint)
Stn<)
6 162
616 2 3 eit lo),
else
62 R
pint+ The toilouwing mo veg a 0quiyedo
fo n-3
The foll ow4 mOVR anL equised o n =3
Wsite u n tion dou he s wlan
ULR copau
dy nomicaly usin aUtiays
Noid inse yt aC)
3Dsts
Count =s12E)
i Cron veaa)
6
o i SIZE -2 izfsont, i --)
A A
sonH
Push ()
Fun tti en push chitcks huthes statk is tull y it is, it cals statk full L)
Smaultn c0d si
totad Even (even 2),
8 Dekine q u . ist
*h di65*3ENT Ps 4aus 3tote the
Lodd>0o
Called ront
ineas q L
oY Simpu qR
else
40ta Odd (odd+2) Double ende Qu
ti)
A odd i) Prioria u u
mitaion Orn0 8uu and nouw 4O olean Isull (Sta ck ma x Stack sige)
Q-NO 3
(no elements in
statk= moa sta tk sige)
13 Wite note on Hekman's untion setuhn TRUE
else
n omputabi thAosy, th AckanmannuaettOn, nomed o vetnn fALSE
wilum Atk emo nn, is one t h e gimplust and auest-disovened
s
eRompks oatotad tompuctable
funttion that not primitw
Statk Push (stak,ittm)
tunetion As total and omputable.
u sive A pimitve e wn sive i s Fuu (sta ak))
n illusttates hod nof a toftal ompucable
a Atkes mann Stads Fu
PimiHve unsive. Atts Acknann's publication ehis n els
authrs inset m into fop e Stack
(whtch had thste n0n negative inteje angume nts), many
it to suit yauous puaposes, So that bodny th Ackama nn
molitid
funten may {es to a numub ants thi ongual hantdn Boolean Tstmpty Lsta x)
two-angument
tekuMann Pete funhon, I(Stack == cAtaks (max Stack size)
Oe tommen vegien, the
nonnegahre integas mnd n: ALkun TRUE
def ined as follws fo
elge
ALfun FALSE
nt
m-
Almn) ln-13)
LA n-1, A(m,n-) my0 & n>o Elemet PoP (Sta.ck) :=
Notice tha not eveny posiion has ght nuighboLDs ektseds move Ls J * arsa movas
tan sor souad e oT each diseution
S o awofd thucking orh bosden tonditons w
* we ae a posion, mage sou [oI3, and we wish to nd pon
bosdes 45 shus aa mxp maRe i Tequ**
MAe b
te n t move, mage[sou1{w), we set:
m+2) P+2) ddia
Tob ek move
Name mov&[divext move[dis]-hosig
oo o O0 o N
NE
oo o o o
St
SS
NW
i-T0-3 N
E Ii+
yofd duuLuR t)
fatorial wwmlb
ecunsive pronomn o
inthude <Ståao.h>
incdude < onio»h prid+duaue s
empty
Noid moinC)
follouoing sules
.mint
vetun n u)S
alamnt eigh prositis p3oussed betose any
insestt) ene- A
Node in thi i
NS4m, Nodt x psecedes a
the tm\n");
Ps Ext
Stanl),d", &1tm)
DEouEvES
st in whith
A dquu oue ended qukua s
med a ithen end but not th
ellmens Can be added 0
middle
Kepye sentstion
be ugad t i nindi
d icot
cae that digyu
aa digs
onditon LEFT NULL w
e
s p DEQUE
heB6sccc bPD J
. 8
2