CMPSC 122 Chapter Notes - Chapter 6: History Of The Web Browser, Pez, Text Editor

41 views1 pages

Document Summary

A stack is a collection of objects inserted and removed with last-in first-out (lifo) ordering. Web browser history and text editor undo function using stacks. Push() inserts elements on top, pop() removes elements off the top. Top() returns a reference to the item at the top of the stack. Adapter design pattern: modify an existing class so that its methods match those of a related but different class or interface. A python list can be repackaged as a stack. Same running times as the list class: Occasionally an o(n) worst case where n is the current number of elements in the stack (caused by resize) Because a stack is lifo, pushing an entire list into a stack and then popping it back out will reverse the list. Stacks can be used to check parentheses and html tags. When an opening delimiter is encountered, push it to a stack. When a closing delimiter is encountered, pop the most recent opening.

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