Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++ Purpose: Use a stack Background: There are 3 main techniques for evalu

ID: 3833785 • Letter: U

Question

Using C++

Purpose: Use a stack

Background:

There are 3 main techniques for evaluating mathematical expressions:

* prefix

* infix

* postfix

Most math classes teach equation evaluation using the in-fix technique. Some calculators use post-fix evaluations, which internally use a stack. Here is an example:

Infix:   (3+4)*5

Postfix: 34+5*   This labs purpose is to use a stack to evaluate an expression.

The technique:

1. Read in a string that has an expression using post-fix notation

2. For each character in the string:

3. If it is a number, push it on the number stack

4. If it is an operator (like +, -, *, /),  

        a. pop two numbers off the stack  

        b. perform the operation  

        c. push the result on the stack   

Part 1: Implement a Doubly-linked-list based on the Singly-linked-list generic interface. Write test code (called a test-bench) to demonstrate the Doubly-linked-list works correctly. Implement an insert and delete at: head, tail, and somewhere between the head and tail.

Part 2: Derive a Stack class inheriting from the Doubly-linked-list. The Stack interface should include:

        Top: Returns the stop of the stack

        Push: Inserts an element on the top of the stack

        Pop: Removes the top of the stack

Read in the Posfix.csv in the documents folder for this week for a list of post-fix expressions to evaluate. If there is an error in the expressions, your program should note the error and then move to the next expression.

Explanation / Answer

part1:

Edit & Run

  std::cin.ignore();          //List object takes care of deletion for us.          return 0;         }  

Edit & Run

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote