Data Strcuture Lab - 05 AIUB
Data Strcuture Lab - 05 AIUB
Data Strcuture Lab - 05 AIUB
1. Write C++ code to convert an infix algebraic expression to a postfix one using the help
of Stack & Queue.
2. Write C++ code to evaluate a given postfix algebraic expression using the help of Stack
& Queue.
For both of these problems, an operand is assumed to be a single digit. And an operator is
limited to ‘+’, ‘-’, ‘*’, ‘/’ (these 4 types). Also, for usage of parentheses, use
only ‘(‘ for opening and ‘)’ for closing.
In light of these remarks, an algebraic expression for example can be written like below:
2*4+(6-3)/3
Follow the instructions from the next slide regarding how to approach the problems 1 and
2.
Instructions to Follow
You are provided with the implementations of Stack and Queue as header files in
your student portal. You will find a zip file containing them.
Download the zip file and use the header files inside for solving problems 1 & 2.
Use the help of the pseudo codes with simulations for both the infix to postfix
conversion and postfix evaluation stated in Theory Lecture 4.2.
Home Task:
Use a stack to reverse a string input by the user. Output the reversed string.
Prerequisites
Have a clear and full understanding of the implementation of Stack & Queue in C++.
To learn how to approach a problem in order to solve it using stack & queue.
To recognize the need of LIFO (Last In First Out) and/or FIFO (First In First Out)
mechanism in a problem.
Books