{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ass2 - CMPSC 461 Fall 2008 Assignment 2 Due October 6 2008...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPSC 461: Fall 2008: Assignment 2 Due October 6, 2008 The code for this assignment should be written in a single file titled <id>_2.ss , where id is your Angel username; similarly, the part in English should be in a file <id>_2.pdf or <id>_2.doc . Note that you will need to use the SLLGEN system for parts of this exercise. Information about SLLGEN is available at the end of the textbook. As before, you should use the dialect of Scheme defined in our textbook—“Essentials of Programming Languages (3rd ed.)” —in PLT Scheme. While doing this assignment, you’ll do well to keep in mind three principles that we have stressed in this class: (A) Follow the grammar to define datatypes; (B) Follow the grammar to prove theorems about datatypes; (C) Follow the grammar while writing routines to manipulate data items. 1. (Queues) A queue is a first-in, first-out data structure. A queue is sketched in the figure below: here, the item a is on the left end , and b is on the right end. You can insert elements into a queue: new elements get inserted on the right end. You can remove elements from the queue: elements get removed from the left end. ! # $%&’( )*+ ,)- )*+ You will now be implementing an abstract data type “queue”. (a) Choose any representation of queues that you like. Write a grammar for this representation. (b) Using define-datatype and following the above grammar, define a data type queue . (c) Choose an interface for queues. Implement the functions in this interface using the data structure you just defined. In the attached text document, write out clearly the names and properties of the functions in this interface (after all, clients have to use it, and you need to communicate to them). Write a small, sample client function that uses some of these functions. (30 points) 2. (Stacks) A stack is a last-in, first-out data structure. Now we will do with them the same things we did with queues. (a) Choose any representation of stacks that you like. Write a grammar for this representation. (b) Using define-datatype and following the above grammar, define a data type stack . (c) Choose an interface for stacks. Implement the functions in this interface using the data structure you just defined. As before, explain the interface in the text part of the submission, and write a small, sample client. (30 points) 3. (Regular expressions) Now we will define abstract data types for regular expressions and finite automata and use them to scan strings.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern