辅导doubly-linked list、讲解CS/Python程序、辅导C/C++设计

- 首页 >> Python编程

Assignment #2: Due 11/12 23:59PM

For this programming assignment, you need to implement (1) a deque class

template using a doubly-linked list and (2) an arithmetic expression conversion

& evaluation function using a deque.

(20 points) In order for a deque to store data in a doubly-linked list, you first

have to reimplement all the list functions like list_insert, list_head_insert,

list_search, list_locate, list_remove, list_head_remove, list_copy, etc. for

doubly-linked lists.

(20 points) Then, implement a deque class template and its member

functions/operators like a copy constructor, destructor, = operator, push_front,

push_back, pop_front, pop_back, front, back, empty using the list-functions

defined above.

Assignment #2: Due 11/12 23:59PM

Implement an expression evaluator class that has the following functions:

(25 points) double evaluate(char[] expr) : evaluates expr in postfix using a deque

and returns the result

(25 points) char[] infixToPostfix (char[] expr) : converts expr in infix into an

expression in postfix using a deque and returns the result

Note that, for this expression evaluator class, you don’t have to define its

member variables.

(10 points)Write your main program that (1) checks to see if all the deque

functions work correctly and (2) takes a valid infix expression from the standard

input and then prints the input expression (in infix notation), its postfix

expression, and the evaluation result using the evaluator member functions.

Assume that (1) all operators(+,-,*,and /) are binary, (2) operands are numbers or

variables and (3) parentheses are allowed in the expression.

If the variables in the expression have to be evaluated, the evaluation routine

should ask the user to enter their values from the standard input.


站长地图