Write client program that uses the stack abstract data type

Assignment Help Computer Engineering
Reference no: EM131858735

Problem

Write a client program that uses the Stack abstract data type to compile a simple arithmetic expression without parentheses. For example, the expression

a + b * c - d

should be compiled according to the following table

Operator

Operand1

Operand2

Result

*

B

C

Z

+

A

Z

Y

-

Y

D

x

The table shows the order in which the operations are performed (*, +, -) and operands for each operator. The result column gives the name of an identifier (working backward from z) chosen to hold each result. Assume that the operands are the letters a through m and the operators are (+, -, *, /). Your program should read each character and process it as follows: If the character is blank, ignore it. If the character is neither blank nor an operand nor an operator, display an error message and terminate the program. If it is an operand, push it onto the operand stack. If it is an operator, compare its precedence to that of the operator on top of the operator stack. If the current operator has higher precedence than the one currently on top of the stack (or if the stack is empty), it should be pushed onto the operator stack. If the current operator has the same or lower precedence, the operator on top of the operator stack must be evaluated next. This is done by popping that operator off the operator stack along with a pair of operands from the operand stack and writing a new line in the output table. The character selected to hold the result should then be pushed onto the operand stack. Next, the current operator should be compared to the new top of the operator stack. Continue to generate output lines until the top of the operator stack has lower precedence than the current operator or until it is empty. At this point, push the current operator onto the top of the stack and examine the next character in the data string. When the end of the string is reached, pop any remaining operator along with its operand pair just described. Remember to push the result character onto the operand stack after each table line is generated.

Reference no: EM131858735

Questions Cloud

Differences between top-down and bottom-up accountability : The criminal justice worker is accountable to whom and why? Discuss the differences between top-down and bottom-up accountability.
Future of digital crimes and digital terrorism : In the United States, a number of law enforcement agencies, including the Secret Service, the Federal Bureau of Investigation
What a forecasting system must do : Considering what a forecasting system must do, select a characteristc of a system (accuracy, cost, flexibility, etc.) and discuss its importance.
Provide a description of an enterprise system : Provide a clear description of an enterprise system and describe how it works.Discuss three ways an enterprise system can provide value for a company.
Write client program that uses the stack abstract data type : Write a client program that uses the Stack abstract data type to compile a simple arithmetic expression without parentheses. For example, the expression
Describe philosophy as a domestic violence advocate : Describe philosophy as a domestic violence advocate, how it developed, and why it would be appealing.
Problem on automobile insurance : Consider an insurance company that wants to underwrite automobile insurance; the actuaries need historical data involving claims and motor vehicle violations.
Identify three possible dissertation research topics : Identify three possible dissertation research topics related to the subject of this course.
Public educators regarding terrorist threats : Are the media the most effective risk, warning, and crisis communicators and public educators regarding terrorist threats

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