32 lines
1.0 KiB
Markdown
32 lines
1.0 KiB
Markdown
# Task
|
|
I want you to write a simple calculator to evaluate arithmetic expressions.
|
|
Solve your problem step by step with C++.
|
|
Please consider the precedence of operators as well.
|
|
|
|
## It includes two parts:
|
|
|
|
- In the first part, you need to convert the input to a postfix expression.
|
|
- In the second part, you need to evaluate the postfix expression that you get in the first
|
|
part.
|
|
- You need to implement your algorithms using c++.
|
|
- You also need to write comment inside the code explaining the following items.
|
|
|
|
## Part 1: Convert an expression to postfix expression using stack in STL
|
|
|
|
1. how to read and store the input?
|
|
2. pseudo code of the algorithm
|
|
3. data structures used in the algorithm
|
|
4. time complexity
|
|
5. space complexity
|
|
6. how to store the postfix expression?
|
|
|
|
## Part 2: Use stack of STL to evaluate a postfix expression
|
|
|
|
1. how to read the postfix expression
|
|
2. pseudo code of the algorithm
|
|
3. data structures used in the algorithm
|
|
4. time complexity
|
|
5. space complexity
|
|
6. how to output the final result?
|
|
|