Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Class notes Data Structure and Algorithms

Rating
-
Sold
-
Pages
5
Uploaded on
21-05-2025
Written in
2022/2023

These handwritten notes on Stack in Data Structures provide a beginner-friendly explanation of concepts like linear queue, circular queue, deque, and priority queue. It includes previous year questions with answers – perfect for quick revision and exam preparation. Ideal for B.Tech, Diploma, and CS entrance-level students.

Show more Read less
Institution
Course

Content preview

Previous Year Questions & Answers –
Stack


1. Define stack. What are the basic operations?
Answer:
A stack is a linear data structure that follows the LIFO (Last In First Out) principle.
The main operations are:
• push() – Add an element to the top
• pop() – Remove the top element
• peek() or top() – View the top element without removing it
• isEmpty() – Check if the stack is empty




2. Differentiate between Stack and Queue
Feature Stack (LIFO) Queue (FIFO)

Insertion At the top At the rear

Deletion From the top From the front

Principle Last In First Out First In First Out

Use cases Undo, recursion Scheduling, buffers




3. What is LIFO?
Answer:
LIFO stands for Last In First Out.
In this system, the element that was added last is the one that is removed first.
Example: A pile of books — the book placed last is removed first.




4. Applications of Stack
• Function call management (call stack)
• Undo/redo in text editors

, • Syntax parsing (HTML/XML)
• Backtracking in games or maze problems
• Expression evaluation (postfix/infix)




5. Stack Overflow and Underflow
• Overflow: When the stack is full and a push() is attempted.
• Underflow: When the stack is empty and a pop() is attempted.




6. Algorithms for Push and Pop (Array)
Push(x):
arduino
CopyEdit
if top == size - 1:
print("Stack Overflow")
else:
top = top + 1
stack[top] = x
Pop():
arduino
CopyEdit
if top == -1:
print("Stack Underflow")
else:
x = stack[top]
top = top - 1
return x




7. Check Balanced Parentheses Using Stack
Logic:

Written for

Institution
Course

Document information

Uploaded on
May 21, 2025
Number of pages
5
Written in
2022/2023
Type
Class notes
Professor(s)
Mr. krishan kumar
Contains
Class 1-3

Subjects

$7.89
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
anujakarmakar

Get to know the seller

Seller avatar
anujakarmakar Government College of Engineering & Textile Technology, Serampore
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
11 months
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions