Stack
1. Stack Operation Simulation
Perform the following operations on an empty stack:
push(5), push(10), pop(), push(7), push(9), pop()
Task:
Write the content of the stack after all operations.
Sample Output:
Final Stack: [5, 7]
2. Reverse a String Using Stack
Given the string:
"HELLO"
Task:
Use stack operations to show how the string becomes reversed step-by-step.
Sample Output:
Reversed String: OLLEH
3. Balanced Parentheses Check
Check whether the following expression is balanced using stack logic:
((a+b)*(c+d))
Task:
Print whether it is Balanced or Not Balanced.
Sample Output:
Expression is Balanced
4. Find the Top Element
Starting from an empty stack, perform:
push(2), push(4), push(6), pop(), push(10)
Task:
Write the top element after all operations.
Sample Output:
Top Element: 10
5. Convert Infix to Postfix
Convert using stack:
A+B
Sample Output:
Postfix: AB+
Queue
1. Basic Queue Operations
Write a C++ program to perform the following operations:
push(10), push(20), push(30), pop(), push(40)
Sample Output:
Final Queue (front → rear): 20 30 40
2. Print Front and Back Elements
Using a queue insert the values,then print the front and back element.
5, 15, 25, 35
Sample Output:
Front: 5
Back : 35
3. Queue Size and Empty Check
Create a queue and insert:
100, 200, 300
Print the queue size, and check whether it is empty using empty().
Sample Output:
Queue Size: 3
Is Empty: No
4. Print Queue Elements by Popping
Insert these elements into a queue:
11, 22, 33, 44
Then print all values by popping one by one.
Sample Output:
Queue Contents: 11 22 33 44
(Queue becomes empty)
5. Count Number of Elements Greater Than X
Insert into queue:
7, 14, 3, 20, 9
Given X = 10, count how many elements are greater than X using STL queue.
Sample Output:
Elements greater than 10: 2