60 likes | 222 Views
STACKS. Pgs. 232-235 Presented by Haylee Glad. STACKS. Restricted linear list in which all additions and deletions are made at one end, called the top Last In, First Out (LIFO) Examples: dishes, coins, or books. PUSH, POP AND EMPTY. PUSH Adds items on the top of the stack
E N D
STACKS Pgs. 232-235 Presented by Haylee Glad
STACKS • Restricted linear list in which all additions and deletions are made at one end, called the top • Last In, First Out (LIFO) • Examples: dishes, coins, or books
PUSH, POP AND EMPTY PUSH • Adds items on the top of the stack • If an item is pushed and there is no room it results in an overflow
PUSH, POP AND EMPTY POP • Removes items from the top of a stack and returns it to the user • If an item is popped when the stack is empty it results in an underflow
PUSH, POP AND EMPTY EMPTY • The response is either true or false • Example: push (S, 10) push (S, 12) push (S, 8) if not empty (S), then pop (8) push (S, 2)
STACK APPLICATIONS • Reversing Data info recorded backwards (ex. input: 1234 output: 4321) • Parsing breaks data into individual pieces for further processing (ex. Key words) • Postponement postpones use of data until a later point • Backtracking goes back to previous data