We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
ID; Kp ECS
Name: Sofek Medi bnest
INHA UNIVERSITY IN TASHKENT
Schoo! of Computers and Information Engineering
Fall semester 2024
Data Structures (SOC2010)
‘Submission Deadline: 20/10/ 2024 (16:45 Hr.) Sunday
NOTE:
1, You are required to take print out of this sheet and solve (handwritten) the questions on sheet
only. [Submissions not conforming to the given format will not be evaluated]
2. Copying of solution is strictly prohibited. in case itis found, then zero marks will be awarded.
8, Submit the scan copy of your solution on eclass. Late submissions are not accepted,
4, You are required to keep a hard copy of the assignment with you. This may be requested at a later
date for verification purposes.
Assignment-2
Questions
1. Consider the following stack, where STACK. is allocated N=6 memory cells
STACK: AAA .DDD,EEE,FFF.GGG.
Describe the stack as the following operations take place:
PUSH(KKK)
- POO)
. PUSH(LLL)
PUSH(SSS)
- POPO
. PUSH(TTT)
Solution:
Sloce ; fat; ODD} EEE, FFF, G&S - A= 37
» push (Ker) iy Steck) AAA) DDDIE EE: RE 666; KKK
2) PeP() > Stace : AAA; DOD ; EEE} FRE GGG
3) Pash(LLd) asiece: AAA! DDD; EEE: FEFiG&G; Ace
- fo == era OW
1) Push (SSS) = Saerf menit EFF: B66
Poh() -> Sfecks Add; SOO ee, EER: 666 TTT
+ . /
gy Dust (TTT) > seen: ABA: DPD:
Row lt:
Aha, pod; =
aun
FE; FEF; G96 777ID: Name:
2. Find the INFIX equivalents of the following POSTFIX expressions:
(a) AB+C*D-
Solution:
L. Read A PAR Sfacu sf
> Pead B t8h srece: A,B
3. Read + ob ien £6 B 3 Stocrf +B)
§ pad * 3(f#8)+C) — Sta: (heal )
C. Peael 0 = Stack ! (A+ B)-c ;
2 Read (-)> (A+ 8)-c)-d
aaate eth c)-b)
(b) ABC *+D-
Solution:
(. Read A Tetb Shece A:
2, Real B —> Stack : ey
3. Remel C —> Sfeck sf, Cc
h. Read (y) > Br@ “5 Slack : Ashe 0)
5. Read GJ > bai)» sae fer
6. Rewel o> Steet: (ABR C
2, pod
fy Beeel iat > (tr Bxc))—D
Result:
OE10: Name:
3. Find the INFIX equivalents of the following PREFIX expressions:
(a) *-+ABCD
Solution:
cides .
Ros + Abe (A+B) + stece [Bice ee]
~ Read — ee rp)-e > Sface (piaea-eL
Bees «— (@+8-9)-0 > Sfaen [eralko)-D
deseLt. ((#+B)-€)-D
(bt) +-A*BCD
Solution:
bead DTS Slece fol
Sfeck [ple
@
2
e Steers [pfelal~
L. Reo x wea Bee = Sfece (ofexe
g Read Ah => Sfece [olore[aé
Pobeedenees (Ce ae [ele=Brel
B-BeCeD > Slace [#-(arcJ+0-
Le Read + =
Result = (A ~(8 2) +0)1: Name:
4. Write a function that accepts two stacks. Copy the contents of first stack in the second stack.
Note that the order of elements must be preserved.
Solution:
vere! copy - stacks( stack a, Sfock Be
Sfoct temp?
Dike (a. ew y() == bale) t
fam p pe sh (a. peee())';
apept); §
Obike (! demmp- 0% pty 0) {
b. push (Kemp. pere)])
tenp-pepl); f