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 DSA Queue

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

It includes easy examples previous year questions with answers – perfect for quick revision and exam preparation.

Institution
Course

Content preview

Previous Year Questions & Answers –
Queue


1. Define a queue. How is it different from a stack?
➢ A queue is a linear data structure that follows FIFO (First In First Out)
principle. The element inserted first is removed first.
A stack follows LIFO (Last In First Out), where the last inserted element is
removed first.




2. Write the algorithm for enqueue() and dequeue() operations.


Enqueue(x):
arduino
CopyEdit
if rear == size - 1:
print "Queue Overflow"
else:
rear = rear + 1
queue[rear] = x
Dequeue():
arduino
CopyEdit
if front > rear:
print "Queue Underflow"
else:
x = queue[front]
front = front + 1
return x

, 3. Applications of Queue:
• CPU scheduling
• Printer spooler
• BFS in graphs
• Customer service systems
• Data buffering




4. What is a circular queue? Why is it used?
A circular queue connects the last position to the first.
It avoids the problem of "false overflow" in linear queues and uses memory efficiently
by wrapping around.




5. Overflow and Underflow in Queue:
Answer:
• Overflow: When the queue is full and cannot insert more elements.
• Underflow: When the queue is empty and we try to remove elements.




6. Difference Between peek() and dequeue():
Answer:
• peek() returns the front element without removing it.
• dequeue() removes the front element from the queue.




7. Queue Using Array (Python Example):
queue = []
# Enqueue
queue.append(10)

Written for

Institution
Course

Document information

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

Subjects

$7.78
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