Ass2 - CMPSC 461 Fall 2008 Assignment 2 Due October 6 2008 The code for this assignment should be written in a single le titled _2.ss where id

Info iconThis 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. (a) Choose a representation and an interface for regular expressions. Write a grammar for regular
Background image of page 1

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

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

This note was uploaded on 09/30/2008 for the course CMPSC 461 taught by Professor Chaudhuri during the Fall '08 term at Pennsylvania State University, University Park.

Page1 / 4

Ass2 - CMPSC 461 Fall 2008 Assignment 2 Due October 6 2008 The code for this assignment should be written in a single le titled _2.ss where id

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online