Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment you will write a program called infix.cpp, that uses a stack, implemented as a singly-linked list, to convert a postfix expression to

image text in transcribed

In this assignment you will write a program called "infix.cpp", that uses a stack, implemented as a singly-linked list, to convert a postfix expression to the corresponding fully-parenthesized infix expression. Consider the following examples: 1. the postfix expression a b + c d - * will be converted to the infix ((a + b) * (c - d)) 2. the the postfix expression a b + will be converted to the infix (a + b) 3. the postfix expression a b / c d / / will be converted to infix ((a / b) / (c / d)) 4. for the postfix expression a b / c * + the program should print the error message "too many operators and not enough operands". 5. for the postfix expression a b c d / + e * f the program should print the error message "too many operands and not enough operators". 6. for postfix expression a will be converted to the infix (a) 7. for an empty (string) expression an empty (string) expression will be returned 8. for postfix + the program should print the error message too many operators not enough operands Notes: 1. Include one space between operands ( eg. a b c d ) and operator (eg. + - * /) in your input to the program. 2. The only operators to consider are +, -, * and /. Your program should ask the user for a postfix expression as input, and it should output the corresponding fully-parenthesized infix expression. The program should also ask the user if he/she would like to do another conversion. If so, the user should be able to enter another posfix expression; otherwise the program should terminate. Also, the stack must be implemented using a singly-linked list. Your driver, infix.cpp, should include the definition and declaration files for the class STACK, stack.cpp and stack.h, respectively. Your program should do error-checking. For example, if the infix expression is invalid, your program should print an error message stating so. You should submit infix.cpp, stack.cpp, and stack.h. in a zip file called "program5_stack" to

In this assignment you will write a program called "infix.cpp", that uses a stack, implemented as a singly-linked list, to convert a postfix expression to the corresponding fully-parenthesized infix expression. Consider the following examples: 1. the postfix expression a b +cd - * will be converted to the infix ((a +b) * (c - d)) 2. the the postfix expression a b + will be converted to the infix (a + b) 3. the postfix expression a b/ c d //will be converted to infix ((a / b) / (c/ d)) 4. for the postfix expression ab/c*+ the program should print the error message "too many operators and not enough operands". 5. for the postfix expression a bcd/+e* f the program should print the error message "too many operands and not enough operators". 6. for postfix expression a will be converted to the infix (a) 7. for an empty (string) expression an empty (string) expression will be returned 8. for postfix + the program should print the error message "too many operators not enough operands" Notes: 1. Include one space between operands( eg, a b c d ) and operator(eg+-* /) in your input to the program. 2. The only operators to consider are +, -, * and /. Your program should ask the user for a postfix expression as input, and it should output the corresponding fully-parenthesized infix expression. The program should also ask the user if he/she would like to do another conversion. If so, the user should be able to enter another posfix expression; otherwise the program should terminate. Also, the stack must be implemented using a singly-linked list. Your driver, infix.cpp, should include the definition and declaration files for the class STACK, stack.cpp and stack.h, respectively. Your program should do error-checking. For example, if the infix expression is invalid, your program should print an error message stating so You should submit infix.cpp, stack.cpp, and stack.h. in a zip file called "program5 stack" to

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago