This project has two parts, a theoretical ("pencil-and-paper") part and a programming part. As with the first project, the "pencil-and-paper" part of this project is to be written up as a comment inside the file with your program. (Put it somewhere near the beginning of the file.) Here are the details.
Part I consists in completing the theoretical representation of the "doublequeue" data type. We will use the following eleven operations, with the following signatures.
create: ? doublequeue
enqueuefront: doublequeue X element ? doublequeue
enqueuerear: doublequeue X element ? doublequeue
front: doublequeue ? element
rear: doublequeue ? element
dequeuefront: doublequeue ? doublequeue
dequeuerear: doublequeue ? doublequeue
isin: doublequeue X element ? boolean
empty: doublequeue ? boolean
size: doublequeue ? number
full: doublequeue ? boolean
Code this all up using Prolog! Specifically, here is what your project should do.
Your code should look for input in a text file called proj2input (no extension). The material in this file is to be read in and processed. Processing this material consists in simulating (or perhaps actually maintaining? Is there a difference?) a double-ended queue.
For this project, a data object of type "element" will simply be a string of lower-case alphabetic characters. A data object of type "number" will be a nonnegative integer.
Your task in Part I is to write up axioms for this definition of "doublequeue". Two hints:
Code this all up using Prolog!
Your code should look for input in a text file called proj2input (no extension).
The input will consist of a series of input units each of which involves applying one of the operations of part I together with (in some cases) additional information. In the case of "front", "rear", "isin", "empty", "size", and "full", your program will have to print out the required information. In the case of ALL the input units, your program is required to print out the current state of the queue after that input unit has been processed.
Output is to be printed to the screen. Make use of lots of "nl" calls to create a reasonable formatting of the output, for readability.
<[url removed, login to view]~cse340/[url removed, login to view]>
Prolog - windows 2000