An infix expression is one in which operators are located

Assignment Help Data Structure & Algorithms
Reference no: EM13380318

An infix expression is one in which operators are located between their operands. This is how we are accustomed to writing expressions in standard mathematical notation. In postfix notation, the operator immediately follows its operands. Examples of infix expressions are:

One advantage of postfix is that unlike infix, no parentheses are necessary. Another advantage is that postfix expressions are easily evaluated using a stack.

This project will require you to create a Java program that will take an input file consisting of several lines of infix notation mathematical calculations, convert them to postfix notation (using the first algorithm in Part1), and evaluate them (using the second algorithm in Part2). The results of the calculations will then be printed to an output file. This project will build on your array and linked list implementations, using them to create your own implementations of stacks and queues for each of the algorithms.

This part will use both a stack and queue in order to convert expressions from infix to postfix notation.

The stack and queue will be implemented by you, using your linked list implementation from labs.

For this part, you will need to maintain two queues and one stack:

- A stack for conversion ‎ Infix to Postfix ‎ (Using Array Implementation)
- A queue for accumulation the digits of the operand (NumQueue) (Using Array Implementation)
- A queue to store the Postfix notation (PostQueue) (Using Linked list Implementation)

Each value will be read from the input line, and dealt with in the following manner:

1. When an operand is read, add it into( NumQueue)

2. When an operator is read

- Convert (NumQueue) into a single floating number, add it into(PostQueue) immediately

- Pop the stack elements and add them to the queue (PostQueue) one by one until the top of the stack has an element of lower precedence

- Then push it into stack.

- When a close-parenthesis [‘)'] is found, pop all the stack elements and add them to the queue (PostQueue) one by one until an open-parenthesis [‘(‘] is found

- When we reach the end of input, pop everything that remains on the stack and add to the queue (PostQueue) one by one.

- Notes : [‘)'] has the lowest precedence when in the stack but has the highest precedence when in the input

When finished converting one statement into a queue in postfix notation, pass the queue (PostQueue) to the next step - the postfix expression evaluator.

Reference no: EM13380318

Questions Cloud

1 list the three fundamental security properties and for : 1. list the three fundamental security properties and for each give an example of failure. justify your answer based on
You are working on a new web site for cruzes inc the web : you are working on a new web site for cruzes inc. the web site is aimed at providing travel information to consumers
The aim of this project is to design developand evaluate a : the aim of this project is to design developand evaluate a 2d game for pc. you can choose any type of game you like
Nbspa stack evaluating the postfix expression lrm using : nbspa stack evaluating the postfix expression lrm using linked list implementationthis step will use the queue
An infix expression is one in which operators are located : an infix expression is one in which operators are located between their operands. this is how we are accustomed to
Design an improved interactive password system present your : design an improved interactive password system? present your design and describe what kind of attacks your protocol can
Convert an erd to a relational schemacovert the extended : convert an erd to a relational schemacovert the extended entity relationship diagram eerd for orthopedic alliance of
Since you have created the data objects for harbor view : since you have created the data objects for harbor view mooring you now need to create processes associated with each
Worldwide advertising inc referred to as wai has hired you : worldwide advertising inc. referred to as wai has hired you as an it consultant for implementing their windows network

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Characteristics that influence the buying decision

Purchaser's perceptions of a item and its value are an important influence on pricing. Value consciousness, price consciousness, and prestige sensitivity are three ways of explaining these perceptions.

  Creating relational database about music performers

Create a relational database having information about music performers, their recordings, and the composers of the music they recorded.

  Lazy version of eager decision tree learning algorithm

Suggest a lazy version of the eager decision tree learning algorithm ID3. What are the advantages and disadvantages of your lazy algorithm compared to the eager algorithm.

  Apply algorithm on string to make substrings

For instance, applying algorithm on string 37540 must make the following substrings (not necessarily in this order): 0; 3; 75; 54; 375; 540.

  Find the shortest path from a to all other vertices

Find the shortest path from A to all other vertices for the following graph:

  Creating dataflow diagram

Think about the level of detail involved with creating a dataflow diagram, why should the narrative be prepared? Explain why do we need the questionnaire?

  Problem 1nbsp what-if and goal-seeking analysis george is

problem 1nbsp what-if and goal-seeking analysis george is planning to set up a new hair salon in a trendy inner city

  Find values of n insertion sort beat merge sort

For inputs of size n, insertion sort runs in 8n 2 steps, where as merge sort runs in 64* nlog base 2 n steps. For which values of n odes insertion sort beat merge sort?

  Consider a queue data structure

Consider a queue data structure, where the two operations of interest are enqueue (at the back of the queue) and dequeue (from the front of the queue). A queue is thus a FIFO (first in-first out) structure. Suppose we implement a queue by using tw..

  What is the logarithm base-2 of zero? of one

What is the logarithm base-2 of zero? of one?

  Identify the most important facts about the diet

Identify the most important facts about the diet. State your opinion about the diet.Support your opinion with relevant facts or research

  Write a flowchart to solve any linear equation ax+b=01.

Write a flowchart to solve any linear equation ax+b=01. W Write a flowchart to solve any linear equation ax^2+bx+C=0

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