CP114 Lecture 5: Abstract Data Types (ADTs)

23 views7 pages
School
Course
Professor

Document Summary

Data items are pushed on top of the stack and popped from the top of the stack. The last item added to the stack is always the first item removed from the stack. Push: push a new value onto the top of the stack. Pop: remove and return the value on top of the stack if one exists, otherwise returns null. Peek: return a copy of the value at the top of the stack without removing it, if one exists, throw an error if the stack is empty. Is_empty: returns true if the stack is empty, false otherwise. Length: returns the number of items in the stack. Data items are added to the rear of the queue and removed from the front of the queue. The first item added to the stack is always the first item removed from the stack. Insert: adds a new value to the rear of the queue.

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