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

Stack Queue Using STL

The document provides an overview of Stack and Queue data structures in C++ using the Standard Template Library (STL). It explains the operations for each structure, including push, pop, and access methods, along with their behavior (LIFO for Stack and FIFO for Queue). A comparison table summarizes the key operations and characteristics of both data structures.

Uploaded by

sidhantkatoch22
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 views4 pages

Stack Queue Using STL

The document provides an overview of Stack and Queue data structures in C++ using the Standard Template Library (STL). It explains the operations for each structure, including push, pop, and access methods, along with their behavior (LIFO for Stack and FIFO for Queue). A comparison table summarizes the key operations and characteristics of both data structures.

Uploaded by

sidhantkatoch22
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 and Queue in C++ STL

CSE/IT JUIT Waknaghat

April 24, 2026

Made by : Akshay Kumar Stack and Queue in C++ STL April 24, 2026 1/4
Stack: Visualization & STL

Container: Stack (LIFO)


top(): Access last element # include < stack >
# include < iostream >
push(): Insert at top
pop(): Remove from top std :: stack < int > s ;

empty(): Boolean check s . push (10) ;


s . push (20) ;
s . push (30) ;

Push Pop if (! s . empty () ) {


// Returns 30
int val = s . top () ;
30 Top // Removes 30
s . pop () ;
20 }

10

Made by : Akshay Kumar Stack and Queue in C++ STL April 24, 2026 2/4
Queue: Visualization & STL

Container: Queue (FIFO) # include < queue >


# include < iostream >
front(): Access first element
std :: queue < int > q ;
push(): Insert at back
q . push (10) ; // First in
pop(): Remove from front q . push (20) ;
empty(): Boolean check q . push (30) ;

if (! q . empty () ) {
// Returns 10
int f = q . front () ;
Pop 10 20 30 Push
// Removes 10
q . pop () ;
Front Back
}

Made by : Akshay Kumar Stack and Queue in C++ STL April 24, 2026 3/4
Comparison Summary

Operation Stack (STL) Queue (STL)


Insert push() push()
Remove pop() (removes top) pop() (removes front)
Access top() front()
Behavior Last-In, First-Out First-In, First-Out
Check Empty empty() empty()

Made by : Akshay Kumar Stack and Queue in C++ STL April 24, 2026 4/4

You might also like