EECS 12 Summer 2006 Homework 8

General Instructions

Please place your programs in seperate files named as described in the problem. Improperly named programs will not count. Turn in your files by placing them in the dropbox. NOTE THAT THERE IS A FIRM DEADLINE FOR THIS HOMEOWRK!!!!

Grading

Correct80%
Commented10%
Attempted10%

Problems

Problem 0: 50 points

Implement a doubly linked list with some functions to operate on them.

Problem 1: 50 points

Write a program called postfix.py that calculates postfix expressions interactively, using a continuous stack and variables.

Below is an example run of the program


> 3 4 5 + *
[27.0]
{}
> 4 5 + 3 *
[27.0, 27.0]
{}
> apple =
[27.0]
{'apple': 27.0}
> 1 + bannana =
[]
{'bannana': 28.0, 'apple': 27.0}
> 5 apple +
[32.0]
{'bannana': 28.0, 'apple': 27.0}
> 32 /
[1.0]
{'bannana': 28.0, 'apple': 27.0}
> 7 orange = 1 2 3*apple-
[1.0, 1.0, -21.0]
{'bannana': 28.0, 'orange': 7.0, 'apple': 27.0}
> ++
[-19.0]
{'bannana': 28.0, 'orange': 7.0, 'apple': 27.0}
> 0 19 -
[-19.0, -19.0]
{'bannana': 28.0, 'orange': 7.0, 'apple': 27.0}
> +
[-38.0]
{'bannana': 28.0, 'orange': 7.0, 'apple': 27.0}
> +
Stack is empty!
[]
{'bannana': 28.0, 'orange': 7.0, 'apple': 27.0}
> quit