Dsa Grp 3 Basic Data Structure Stack Final
Dsa Grp 3 Basic Data Structure Stack Final
PRESENTATION
Group 3 Reporters
• Balbin, Jrob Francis G.
• Bernales, Lance Christian
• De Sagun, Lorraine Frances
• Navos, Nathan East
• Opiz, Josef Andrei
Basic Data
Structure Stacks
Basic Data Structure Stacks
Stacks Operations
Pop, Push, Top
Parsing and Evaluation of Arithmetic
Expression using stacks
Postfix and Infix Notation
Sample Programs
ICE BREAKER
LET’S GOOO!!!!
ICE BREAKER
swap two variables without using a
temporary variable, relying on basic
arithmetic operations (addition and
subtraction).
LESSON PROPER
Defining Stacks
Stack Operations
Stack Operations
Example
stack<string> cars;
Basic operations
.push()
To add elements to the stack
Basic operations
Example
stack<string> cars;
stack<string> cars = {"Volvo",
cars.push("Volvo"); "BMW", "Ford", "Mazda"};
cars.push("BMW");
cars.push("Ford");
cars.push("Mazda");
Basic operations
.top()
returns the top element on the stack.
Example
cout << cars.top();
Basic operations
.pop()
To remove an element from the stack.
Example: stack<string> cars;
cars.push("Volvo");
cars.push("BMW");
cars.push("Ford");
cars.push("Mazda");
cars.pop();
A + B, (A x B) - C
Postfix Notation - In postfix notation, operators are placed after
their operands.
AB+, ABCx-
Postfix & Infix Notation
Operator Priority/Precedence
Infix: A+B*C-D/E
Operand
Operator
Postfix: ABC*+DE/-
Operand
Postfix & Infix Notation
Operator
Infix: 5+3*2-8/4 =9
Operand
Operator
Postfix: 532*+84/- =9
Operand
Postfix & Infix Notation
Infix Expression
5+3*2-8/4 = 9
Postfix Evaluation
Step 1: 5 3 2 * + 8 4 / - = 56+84/-
Step 2: 5 6 + 8 4 / - = 56+2-
Step 3: 5 6 + 2 - = 11 2 -
Step 4: 11 2 - = 9
Sample
Program
Conclusion
Thank you
for listening!
QUIZ TIME
SEATWORK
LAB ACT 3
GROUP 3
PRESENTATION