CSI 2110 Lecture Notes - Lecture 4: History Of The Web Browser, Linked List, Text Editor

26 views3 pages

Document Summary

Main methods push(o) inserts object o at top of stack removes and returns top object pop() (error if the stack is empty) Support methods returns # of objects in stack size() isempty() returns boolean indicating if stack is empty. Returns top object without removing top() (error if the stack is empty) Auxiliary data structure for algorithms (eg. implanting a queue with 2 stacks) Example: evaluating an arithmetic expression with 2 stacks. Example: checking for balanced parenthesis in an arithmetic expression. Stack, s, consists of an array with n elements and an integer t that indicates the index of the top element in the stack. Space usage is o(n), where n is the size of the array determined when the stack is initiated, and is independent from the # of elements on the stack (n<=n) The main drawback to this implementation is that the arraystack is a static structure and has a fixed capacity.

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