1 views

Uploaded by Nurain Ali

stackk

- FileIO_Cprogram
- Stack
- Using the Scientific Calculator
- Cs2309 Lab Pgms
- ruby_bits_2_level_4
- Anuj Project File
- Data Structures
- Cs301 Assignment Solution
- 81423ws
- syllabus
- ARDUINO
- CAP267 dsa.pdf
- Reverse Polish Notation Calculator
- brabrabra
- DS
- datastructures syllabus
- Data Structures
- WINSEM2015-16_CP1221_25-Jan-2016_RM01_P5--8051-Assembly-Language-Programming-1.pdf
- Algorithm Infixtopostfix
- 8051 Registers

You are on page 1of 8

By : Imam M Shofi

What is stack?

array.

New elements, or nodes as they are

often called, can be added to a stack

and removed from a stack only from

one end.

Access system a stack is referred to

as a LIFO structure (Last-In First-Out)

Some illustrations:

stack of satay

stack of CDs

Stacks operations

Push

Pop(S) removes the TOP node and returns its

value

IsEmpty

empty

IsFull

Initialize

stack (may be implemented by reinitializing the stack)

Destroy(S) deletes the contents of the stack S

Illustration/example

Operation

Stacks contents

TOP value

1. Initialiaze(S)

<empty>

2. Push(a,S)

3. Push(b,S)

4. Push(c,S)

5. Pop(S)

6. Push(d,S)

7. Push(e,S)

8. Pop(S)

9. Pop(S)

10. Pop(S)

a

ab

abc

ab

abd

abde

abd

ab

a

1

2

3

2

3

4

3

2

1

Exercise

following operations:

create stack

push A onto stack

push F onto stack

pop item from stack

push B onto stack

pop item from stack

pop item from stack

Show the state of the stack and the value of each

variable after execution of each of the following

statements:

A=5

B=3

C=7

(a)

create stack

push A onto stack

push C*C onto stack

pop item from stack and store in B

push B+A onto stack

pop item from stack and store in A

pop item from stack and store in B

(b)

create stack

push B onto stack

push C onto stack

push A onto stack

A=B*C

push A+C onto stack

pop item from stack and store in A

pop item from stack and store in B

pop item from stack and store in C

Do the second brace: (C*D), the PREFIX is *CD

The end is operator -: +AB - *CD,

the PREFIX is -+AB*CD

Do the first brace: (A+B), the POSTFIX is AB+

Do the second brace: (C*D), the POSTFIX is CD*

The end is operator -: AB+ - CD*,

the PREFIX is AB+CD*-

operator (A and B), the INFIX is (A*B)

Find the second operator: /, take 2 operands before the

operator (A*B and C), the INFIX is ((A*B)/C)

Find the third operator: +, take 2 operands before the

operator (((A*B)/C) and D), the INFIX is ((A*B)/C)+D

operator (A and B), the POSTFIX is AB*

Find the second operator: /, take 2 operands before the

operator (AB* and C), the POSTFIX is AB*C/

Find the third operator: +, take 2 operands before the

operator (AB*C/ and D), the POSTFIX is AB*C/D+

Find the first operator: *, take 2 operands before the

operator (C and D), the INFIX is (C*D)

Find the second operator: /, take 2 operands before the

operator ((C*D) and B), the INFIX is (B/(C*D)

Find the third operator: -, take 2 operands before the

operator ((B/(C*D) and A), the INFIX is A (B/(C*D)

operator (C and D), the PREFIX is *CD

Find the second operator: /, take 2 operands before the

operator (*CD and B), the PREFIX is /B*CD

Find the third operator: -, take 2 operands before the

operator (/B*CD and A), the PREFIX is -A /B*CD

Exercise: Converting

Convert these INFIX to PREFIX and POSTFIX :

1.

a)

b)

c)

A/BC/D

(A + B) ^ 3 C * D

A ^ (B + C)

2.

a)

b)

c)

+ /AB C ^ D E

+DE/XY

^+23CD

3.

a)

b)

c)

ABC+

GH+IJ/*

AB^CD+

- FileIO_CprogramUploaded byKoustubh Banerjee
- StackUploaded byزهرة النرجس
- Using the Scientific CalculatorUploaded byeatcows1
- Cs2309 Lab PgmsUploaded byMagesh Karthik
- ruby_bits_2_level_4Uploaded byLe Tan Phat
- Anuj Project FileUploaded byamaranandminz
- Data StructuresUploaded byMuhammad Ali
- Cs301 Assignment SolutionUploaded bycs619finalproject.com
- 81423wsUploaded byTurcan Ciprian Sebastian
- syllabusUploaded bypranay
- ARDUINOUploaded byKevin Wladimir Columba
- CAP267 dsa.pdfUploaded byAmar Deep
- Reverse Polish Notation CalculatorUploaded bytarik
- brabrabraUploaded byEys Gab
- DSUploaded byNeha Arora
- datastructures syllabusUploaded bysampathabo
- Data StructuresUploaded byDevi Alagappan
- WINSEM2015-16_CP1221_25-Jan-2016_RM01_P5--8051-Assembly-Language-Programming-1.pdfUploaded byKaushal Faujdar
- Algorithm InfixtopostfixUploaded bysami.yaha
- 8051 RegistersUploaded byNishant Kumar
- Computer Programming (for)Uploaded byBank
- railwayUploaded byDivya Batra
- Item Load PKGUploaded byRalph Khan
- Assessment 4Uploaded byksmohana
- csUploaded bymarwa
- syllabus for c programming 2017Uploaded byapi-327629533
- @anilUploaded byclassveb
- AanmaUploaded byRamasamyRajkumar
- InheritanceUploaded byNandaShivani
- Alice02 WebUploaded bydalilah_821

- 00230513022011Uploaded byNurain Ali
- Earned Value Tutorial ForBPMUploaded byNurain Ali
- Case Study of AirAsiaUploaded bytan_san_8
- Air AsiaUploaded byNurain Ali
- Exercises Final Exam Part1Uploaded byNurain Ali
- Proposal Chapter 2 1Uploaded byNurain Ali
- 12 ReviewUploaded byNurain Ali
- m8-folUploaded byNurain Ali
- Cps270 First Order LogicUploaded byNurain Ali
- ds6Uploaded byNurain Ali
- OSHA Assesment FormUploaded byNurain Ali
- 210ch3part1Uploaded byNurain Ali
- 35-DijkstrasAlgUploaded byNurain Ali
- 16 Relations IntroUploaded byNurain Ali
- MCUploaded byNurain Ali
- Discussion Questions Case Study IIUploaded byNurain Ali
- q&a-ch4Uploaded byNurain Ali
- Approval to visit factoryUploaded byNurain Ali
- week10Uploaded byNurain Ali
- Traffic&PedestriansurveysUploaded byNurain Ali

- Wpc Certification ServiceUploaded byRavindran Kodakkattil
- Engineeringcivil.com-M25 Mix Designs as Per IS102622009Uploaded bygdesh90
- Bill of Material CreationUploaded bysandeshbhavsar
- LeBlond's Dual Drive Lathe SmallUploaded by4U6ogj8b9snylkslkn3n
- Unit 2 Tutorials.docxUploaded byNavin Narine
- Drill Collars DetailsUploaded bysumanpadakandla
- Forecasting Stocks with Multivariate Time Series Models.Uploaded byinventionjournals
- MBA Finance & Marketing _ Resume CV BioData, Curriculum Vitae, Sample Format, Cover LetterUploaded bycool123uday
- Thinstuff Manual XPVS 1.0.2 EnUploaded byAwai Agung
- Polar Bears and Penguins (1)Uploaded byPrueba3
- Dove Soft Pvt Ltd Intl Dest PlUploaded bySharron Woodbridge
- Textual Analysis the Ring PDFUploaded byAnonymous sIna6Yn
- mozart movement 1Uploaded byapi-254098177
- Abbott I-STAT 1 Operator GuideUploaded bymarchie525
- Radon Testing ResultsUploaded byWSET
- Metal Gods of Ur-Hadad 1.pdfUploaded byMatt Gullett
- 2014-10-12Uploaded byAnonymous jQItd9jtc0
- Maritime StudentUploaded byicy
- axcelUploaded byJoenell Cardino Galve
- A Short History of DerivativesUploaded byJasmeet Gujral
- csir2010dec1Uploaded bymousumimamun
- Colin Drury Cost AccountingUploaded byAhmed Ali Khan
- Form of Convertible Promissory Note BoilerplateUploaded byScoreFinancial
- A1.1 Wurms AudiUploaded byqingcaohe
- The Hidden Mysterious Fundamental Forces and How Knowledge Management Discovered ItUploaded byMd Santo
- Giancarlo TomezzoliUploaded byBogNS
- CourteneyUploaded byramlohani
- BK 1653A ManualUploaded bydavesxp
- is.11228.1985Uploaded byBhaskar Reddy
- Transaction Codes abapUploaded bySai Raj Yadav