Converting an expression from infix to postfix

Assignment Help C/C++ Programming
Reference no: EM131740239 , Length: 1

Apply the following algorithms in c++:

1- Converting an expression from infix to postfix

opstk= the empty stack;
while (not end of input) {
symb=next input character;
if (symb is an operand)
add symb to the postfix string
else {
while (!empty()&&prcd(stacktop(), symb)) {
topsym=pop();
add topsymbto the postfix string;
} /*end while*/
if (empty() II symb != ‘)')
push(symb);
else /* pop the open parenthesis and discard it */
topsymb= pop();
} /* end else*/
} /* end while*/
/*output any remaining operators*/
while (!empty()) {
topsymb=pop();
add topsymb to the postfix string;
} /* end while*/

2- Evaluating a postfix expression

Opndstk= the empty stack;
/* scan the input string reading one element at a time into symb*/
while (not end of input) {
symb=next input character;
if (symb is an operand)
push(symb);
else{
/* symb is an operator*/
opnd2=pop();
opnd1=pop();
value=resulr of applying symb to opnd1 and opnd2;
push(value);
} /* end else*/
} /* end while*/
return (pop());

Reference no: EM131740239

Questions Cloud

Trading in the markets on a day-to-day basis : Given that a company receives funds only from transactions in the primary market for common stock, why should financial managers care.
Implement the given operations of a queue using stacks : Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue.
How is kac pushing art forward in the digital age : How is Kac pushing art forward in the digital age? Use examples from the presentation. Why do you feel this way towards his work?
Define technique used to compare the equality of means : ANOVA is a hypothesis testing technique used to compare the equality of means for two or more groups
Converting an expression from infix to postfix : Data structures CS-214 - Converting an expression from infix to postfix and Evaluating a postfix expression -
Discuss the issues of availability versus confidentiality : Discuss the issues of availability versus confidentiality of the DR and BC plans. The recommendation is for all DR team members to have several copies.
In economics what is meant by an oligopoly : What are some ways to make a distinction between an Oligopolistic Market and a Market identified as having Monopolistic Competition?
What are the key characteristics of a simulation : Define the terms "Game" and "Simulation" as they relate to eLearning.What are the key characteristics of a Simulation?
Write a report paper about absenteeism employees : Write a report paper about absenteeism employees. It tells you the purpose of the report, how the issue was investigated, a findings ...

Reviews

len1740239

11/28/2017 1:02:50 AM

The discussion will be in the lab lecture at week 12. You have to send your answer before your lab lecture. Data structures CS-214 Apply the following algorithms in c++: Evaluating a postfix expression - pop the open parenthesis and discard

Write a Review

C/C++ Programming Questions & Answers

  Many bank atm machines have recently added the ability to

many bank atm machines have recently added the ability to dispense cash with- drawals in multiple bill denominations

  Write a c program that prompts the user to enter some data

Write a C program that prompts the user to enter some data regarding some clients. The user should prompt for client account number (a UNIQUE positive integer between 1 and 1000).

  Lab9 c lab 9 c i request this twice but no answer on this

lab 9 c ltbrgti request this twice but no answer on this please could you check this for

  Design a deck plan space ship in eclipse

Develop a simple interactive two-dimensional spaceship deck plan editor using OpenGL and GLUT. Your program will enable a user to create and save a deck plan of a hypothetical spaceship comprising the hull walls.

  Program that takes the purchase price of two item

Program that takes the purchase price of two items and compares the prices of those items under two different discounts (half-off the second item, and a percentage off both items (i.e. 10% off)).

  Write program that print a diamond shape featuring asterisk

For this assignment, we will need to write a c++ program that is print out a diamond shape featuring the * asterisk to the console window. Please submit .cpp file.

  Create four child processes

1. Using Fork() and Exec() or Clone(), create four child processes. Load the same “Hello” program in each process after creation. This program should behave differently in each process.

  Write a c++ program that reads a set of integers

Write a c++ program that reads a set of integers and then finds and prints the sums of the even and odd numbers.

  Write a program that allows user to choose starting point

Write a program that allows the user to choose the starting point for the iterations with the mouse, and draw the dots for the gingerbread man.

  Declare a pointer vptr that points to an object

Declare a pointer vPtr that points to an object of type unsigned int

  Implement a rotate function

Write and test the following function: void rotate(int a[], int n, int k); The function "rotates" the first n elements of the array a, k positions to the right.

  Write program to input series of hourly temperatures

Create and write a c++ program which inputs series of 24 hourly temperatures from file, and outputs bar chart (using stars) of temperatures for the day.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd