CSC148H5 Lecture 2: Lecture 2

114 views1 pages
1 Apr 2018
School
Course

Document Summary

It"s a data type, so it stores data, and. It is abstract, so we ignore how it"s implemented. We describe it from a user"s point of view, not an implementer"s pov. Adt allows us to directly describe the data used in our problems, independent of implementation details. What adt did we learn in csc108 example: dictionary (dict) data stored: a collection of key- value pairs operations: Stack adt data stored: a sequence of objects operations: Push(o): add a new item o to the top of the stack. Is_empty(): test if stack is empty could also have: Peek(): return top item (without removing it) Size(): return number of items in stack. Option 1: use a python list l, add and remove at the end of the list. Is_empty(): return len(l) == 0 option 2: use a python list l, add and remove at the beginning of the list.

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