assignment3 - Assignment 3: Inx to Postx Notation Problem...

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

View Full Document Right Arrow Icon
Assignment 3: Infix to Postfix Notation Problem Solving with C++, Spring 2008 Due: March 12th, 11:53pm Objectives The objectives in this assignment are: 1. Practice programming dynamic data structures with pointers . 2. Think modularly (in terms of representation) when designing your program. Separate interfaces and implementations. 3. Learn to plan ahead. This is a big assignment and you will need to work on it in stages. 4. Gain practice coding and debugging algorithms. Overview Humans write expressions 3 + 4 and 7 / 9 in infix notation – the operator is written between its operands. Com- puters prefer postfix notation in which the operator is written to the right of the operand, such as, 3 4 + and 7 9 / . To evaluate a complex infix expression, a compiler would first convert the expression to postfix notation and then evaluate the postfix notation. The algorithm that converts an infix arithmetic expression (consisting of single digit integers) to a postfix expression is given below. Algorithm: Infix to Postfix Read the given expression into an array named infix. The output will be stored in an array called postfix. You need a stack to perform the conversion. The steps are as follows: 1. Push a left parentheses into a stack. 2. Append a right parentheses to the end of infix. 3. While the stack is not empty, read infix from left to right and do the following: (a) If the current character in infix is a digit, copy it to the next element of postfix
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.

Page1 / 4

assignment3 - Assignment 3: Inx to Postx Notation Problem...

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