CSC148H5 Lecture 2: Lecture 2
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.