Create three stacks of characters

Assignment Help Computer Engineering
Reference no: EM131863913

Assignment

A prefix expression is one where each operator appears before its two operands. For example the fully parenthesized infix expression ( ( ( a + b) / (c+d) ) * (e / f) ) becomes the prefix expression * / + a b + c d / e f. The object of this assignment is to write a program to convert a fully parenthesized infix expression to its equivalent prefix expression. Assume the input infix expressions consist only of variables a through z, operators +, -, *, / and parentheses '(', ')' . Use the following algorithm:

(1) Create three stacks of characters: stk1, stk2, stk3.

(2) Read the input infix expression one character at a time and push every character read ( other than ')' ) onto stk1. Do not push the character read if it is ')'.

(3) As long as stk1 is not empty, do the following:

Fetch the top character ( call it c ) of stk1 and pop stk1.

if c is an alphabetic character (a-z), push it onto stk3. (You can use the function islower(c) to test if character is one of a-z.)

if c is an operator, push it onto stk2.

if c is '(' then fetch the top character of stk2, push it onto stk3, and pop stk2.

(4) Print stk3 top to bottom by repeatedly fetching the top of stk3, printing it, and popping stk3, until stk3 is empty.

There is starter code in folder Hwk3 in your course folder on comsci. Open the project file Hwk3.cbp in codeblocks and complete the program hw3.cpp in that project.

The program uses the class template stack from the standard C++ library. Check the examples on the slides for how to push, pop, and check for empty stack.

Attachment:- Tepmlate.rar

Reference no: EM131863913

Questions Cloud

How were the winds of the indian ocean used for trade : How were the winds of the Indian Ocean used for trade with Asia. How do ships travel the seas now
Serenity massages has decided to create exciting : To boost sales, Serenity Massages has decided to create an exciting, new advertising campaign.
Discuss the problem of coordination : Consider the major federal law enforcement agencies and then briefly discuss the problem of coordination. Use smuggling to illustrate the challenge.
Discuss the difference between centralized and decentralized : Use the highway patrol or state troopers to discuss the difference between centralized and decentralized state law enforcement models.
Create three stacks of characters : Create three stacks of characters: stk1, stk2, stk3. Read the input infix expression one character at a time and push every character read onto stk1.
How were the trade winds used for exploration : During the Age of Exploration, why was the discovery of wind patterns so important to the 15th century Portuguese? How were Trade Winds used for exploration
Head of a local law enforcement agency : Suppose you are the head of a local law enforcement agency. Identify two lessons you would take away from the Sheriff Joe Arpaio case.
Federal responsibility for immigration matters : Briefly discuss the tension between local control in policing and the federal responsibility for immigration matters.
Major sections of your evidence-based-practice proposal : repare a PowerPoint presentation of 10-15-slides that covers all major sections of your Evidence-Based-Practice Proposal paper.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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