0% found this document useful (0 votes)
2 views2 pages

Stack and Queue Operations Explained

The document outlines various stack and queue operations, including push, pop, and methods for reversing strings and checking balanced parentheses. It also describes how to convert infix expressions to postfix and provides basic operations for queues, such as checking size and emptiness. Additionally, it includes a method for counting elements greater than a specified value in a queue.

Uploaded by

mashrafianam99
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Stack and Queue Operations Explained

The document outlines various stack and queue operations, including push, pop, and methods for reversing strings and checking balanced parentheses. It also describes how to convert infix expressions to postfix and provides basic operations for queues, such as checking size and emptiness. Additionally, it includes a method for counting elements greater than a specified value in a queue.

Uploaded by

mashrafianam99
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Stack Operation Simulation

Explanation:
push values to stack
pop removes last pushed
transfer stack→vector to view in correct order
reverse restores original bottom→top order

Reverse String Using Stack

Explanation:
push each char
pop one-by-one to build reversed string

Balanced Parentheses

Explanation:
push '('
when ')' appears:
if stack empty → not balanced
else pop
end: balanced if stack empty

Find Top Element

Explanation:
simulate push/pop
[Link]() gives last pushed element

Infix to Postfix

Explanation:
direct literal output AB+

Queue Basic Operations

Explanation:
push adds to rear
pop removes from front
print sequentially while popping
Front & Back of Queue

Explanation:
front() = first inserted
back() = last inserted

Queue Size & Empty

Explanation:
size() gives count
empty() tells if queue has elements

Print Queue by Popping

Explanation:
print front and pop until empty

Count Greater Than X

Explanation:
compare each front value with X
increment counter if greater

You might also like