CS234 Lecture Notes - Double-Ended Queue, Maximum Capacity, Increment And Decrement Operators

43 views4 pages

Document Summary

A stack is a linear collection of items, addition and removal of items in a stack take place from exactly one (the same) end called the lifo protocol (last in first out) Example: a garage with one door that can hold 3 cars: car three comes in last and has to go out first, car 1 comes in first but can only go out last. |car1 car2 car3| garage door with 3 cars in the garage. Another example is a tennis ball container the last in tennis ball is the first out tennis ball. Push: add to the top; pop = remove from the top. The code takes element 1 of l and pushes in onto the stack, continues to do this until the list becomes empty. Then until stack is empty, pop off the top value of stack repeatedly and append it to l. At the end of the two while loops, l = [11,9,8,-1,2,10,5]

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents