CS 136 Tutorials - Spring 2007

Tutorials »

Tutorial 3: ADTs (May 18)

Today's tutorial focuses on Abstract Data Types (ADTs) and how to implement them in PLT Scheme's object/class system. These concepts are introduced in Lecture Modules 3 and 4 (see Handouts).

  1. Double-ended queue
  2. Here is a description of the double-ended queue (DEQ) ADT:

    A DEQ is a (possibly empty) sequence of values d1, d2, ..., dn. There are five operations on DEQs, as follows:

    Implement the double-ended queue ADT as a class called DEQ% in Scheme.

  3. Playing Cards
  4. The following is a description of the Card ADT:

    A Card is a pair (r,s), where r (the "rank") is an integer in the range [1,13], and s (the "suit") is one of the four words "spades", "hearts", "clubs", or "diamonds". Cards are immutable, and so all preconditions and postconditions of all operations are "true". A Card has the following operations:

    Implement the Card ADT as a class called card% in Scheme.

Last modified on Wednesday, 09 January 2019, at 14:31 hours.