stacks
play

Stacks Stack - a collection of ADT objects that stores - PowerPoint PPT Presentation

Stacks Stack - a collection of ADT objects that stores Insertions 4 removals follow a n . Last - in - first - out pattern < Basic Operations : ' ' top an element at the inserts push : removes t returns the top .


  1. Stacks

  2. ⇒ ⇐ ⇒ Stack - a collection of • ADT objects that stores Insertions 4 removals follow a n . Last - in - first - out pattern < Basic Operations : ' ' top an element at the inserts push : removes t returns the top . element : pop ÷ : 7¥ ' : :* empty stack

  3. Stack = - Convienient but optional operations : check for emptiness is Empty : n . on stack elements # return size : return top , but don't remove it top : - Algorithmic applications : . parsing levaluat.com/ transformation of expressions Is peach recognition ; coding ( decoding network access control • shared . → programming languages £ execution - Postscript , Forth , the call stack we do daily with computers • things . . .

  4. Parenthesising 0 0 a 0 • 00 ⑨ a @ 0 @ eg b @ a 0 a 41441*11 × Can be done by counting : iciii 1) 111 Chill 'D 114 I 0 -1 0 -7 12 I 21 01 4 23 2 10 1 2 1 Checking Multiple Grouping Symbols : llllmn 1113 (4) pp TT T - Counting is enough not .

  5. Astack-basedalgorithmforcheckinggroupingsymbubss-ne.no empty stack symbols to read there while are symbol next C ← symbol left if a e is S push con else is empty if report S error S d * pop match report if not c. d do while end report error if empty not 5 is " ok " report

  6. 5tack-partially-tikedArraytmplemewtationkariablesi.FI - array of stack elements ' capacity - size of array - index in array of top stack element top is empty - -1 if stack irrelevant - D Alot A pacify I = ! ⇐ A = { size of A) capacity top = 2 I If push e A- tT } egg = { size of A) = capacity top =3

  7. Stack : Linked List Implementation = ±f - 3 t.tot.EDU Which end shout be the top ? = front of list - top at top • push = insert add - to - front list = normal I linked = top . = remove from front pop - from - front . = normal linked list remove i.FI#--GI5.FJ-oIaD-HJ=a b- ↳ pop → D- ④

  8. staekImplemewtat.cn# 4 are push - In both pop cases , operations constant time stack does not get ( as long as the larger array ) . than the

  9. End

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend