This outline is also available in PDF.
Held: Monday, 27 November 2006
Today we consider abstract data types in general and a particular abstract
data type, the stack.
- Tons of cool talks this week: Today, 1:15 (2417): Eye Tracking; Today, 4:15 (CCC): Assistive Technologies for Art; Thursday, 11:00 (2424): Interactive Character Animation; Thursday, 9:00 p.m. (2424): Rockstar Games Presents Table Tennis; Friday, 4:15 p.m. (2424): Careers in the Gaming Industry.
- Happy purgatory week!
- Are there questions on the exam?
- Abstract Data Types (ADTs).
- Implementing Stacks in Scheme.
- Some Applications.
- As you've noted, when working with data we find many different ways to organize the data.
- If we want to access information quickly by number, we use a vector.
- If we want to add and remove information, we use a list.
- If we want to access information by name, we use an association list.
- Good programmers decide on the key operations they wish to perform and then find the best possible implementation of those operations.
- A natural set of related operations is often called an abstract data type.
- The corresponding implementation of those operations is often called a data structure.
- Stacks are an abstract data type with a few simple operations.
- Think about a stack of books or papers on a desk.
- You can add something to the top of the stack. Computer scientists call this operation push.
- You can remove something from the top of the stack. Computer scientists call this operation pop.
- You can look at the top of the stack. Computer scientists call this operation top or peek.
- It is fairly easy to implement stacks in Scheme.
- We represent the stack as a list, with the newest item at the front.
- To push something, we cons it onto the front.
- To pop something, we cdr the list.
- How do we change a list in place? We don't, really. Instead, we store
the list in a vector, and reset the contents of the vector.
- To make things even more fun, let's use object-oriented programming techniques.
- RPN calculator.
- Eliminating deep recursion.
- Matching tags in HTML.