0% found this document useful (0 votes)
19 views11 pages

08 AshleshKadam21

The document outlines a laboratory exercise for a Data Structure course focusing on implementing linear queue operations using C programming. It includes an algorithm for enqueue and dequeue operations, practical questions, and applications of queues in various domains such as operating systems, networking, and customer service. Additionally, it describes the characteristics and properties of queues as an Abstract Data Type (ADT).

Uploaded by

ashleshkadam8g21
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)
19 views11 pages

08 AshleshKadam21

The document outlines a laboratory exercise for a Data Structure course focusing on implementing linear queue operations using C programming. It includes an algorithm for enqueue and dequeue operations, practical questions, and applications of queues in various domains such as operating systems, networking, and customer service. Additionally, it describes the characteristics and properties of queues as an Abstract Data Type (ADT).

Uploaded by

ashleshkadam8g21
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
You are on page 1/ 11

DEPARTMENT OF COMPUTER ENGINEERING

Subject: DSU Subject Code: 313301

Semester: III Course: DATA STRUCTURE USING C

Laboratory No: V120 Name of Subject Teacher: Vijayalakshmi Ma’am

Name of Student: Ashlesh A Kadam Roll No: 23203A0008

Experiment No 21

Title of Experiment *Write a 'C' Program to perform INSERT and DELETE

Operations on Linear Queue using an Array.

Insert and delete operations on linear queue using array

Algorithm:-
1. Initialize Variables:
2. Declare an array q of size SIZE to represent the queue.
3. Initialize two pointers front and rear to -1 to indicate the empty queue state.
4. Display Menu:
5. Show the user the following options:
a. 1: Add (Enqueue) an element to the queue.
b. 2: Delete (Dequeue) an element from the queue.
c. 3: Display the elements in the queue.
d. 4: Quit the program.
6. Loop until the user chooses to quit:
7. Ask the user for a choice of operation (ch).
8. Process the user’s choice:
9. Case 1: Add (Enqueue):
a. Check if the queue is full:
i. If rear == SIZE - 1, print "Queue overflow".
b. If not full:
i. Prompt the user to input the element to be added.
ii. If the queue is initially empty (front == -1 and rear == -1), set front = 0
to indicate the first element.
iii. Increment rear and add the new element to q[rear].

Page | 1
10. Case 2: Delete (Dequeue):
a. Check if the queue is empty:
i. If front == SIZE or front == -1, print "Queue underflow".
b. If not empty:
i. Print the element at q[front] as the deleted element.
ii. Increment front to move the front pointer to the next element.
11. Case 3: Display Queue:
a. Print all elements in the queue from q[front] to q[rear].
12. Default Case:
a. If the user enters an invalid option, print "Wrong choice".
13. Repeat until the user selects option 4 (Quit).
14. End.

Code:-

Page | 2
Output:

Page | 3
Practical Related Questions:

1. Write a C program to demonstrate Queue Underflow and Queue


Overflow.

Page | 4
OUTPUT:-

Page | 5
2. Write a C program to implement a linear queue with operations for enqueue
(15), enqueue (48), enqueue (69), dequeue, enqueue (12), enqueue (23), dequeue,
dequeue checking if the queue is empty or full, and displaying the current queue.

Page | 6
Page | 7
OUTPUT: -

Exercise:

1.Describe Queue as Abstract Data Type (ADT).


Queue as an Abstract Data Type (ADT)

A Queue is an Abstract Data Type (ADT) that operates on the principle of FIFO
(First-In, First-Out). The first element added is the first to be removed.

 Key Characteristics
Basic Operations:

- Enqueue: Add an element to the back of the queue.


- Dequeue: Remove an element from the front.
- Peek/Front: Return the front element without removing it.
- IsEmpty: Check if the queue is empty.
- Size: Return the number of elements.

Properties:

- FIFO Order: Elements are processed in the order they were added.
- Dynamic Size: The queue can grow or shrink as needed.

Page | 8
Applications

- Task Scheduling: Manages processes in operating systems.


- Breadth-First Search: Explores graph nodes level by level.
- Print Queue: Handles print jobs in the order they are received.

2.Give applications of Queue in different domains.

Queues have a wide range of applications across various domains. Here are
some key applications:

 Operating Systems
- Process Scheduling: Queues manage processes in a system, allowing the
CPU to handle tasks in a fair and orderly manner, often through ready
queues and job queues.
- I/O Buffers: Queues are used to hold data from input/output devices
until the CPU is ready to process it.

 Networking
- Packet Queuing: In routers and switches, packets are queued before they
are forwarded, ensuring data packets are sent in the order they are
received.
- Print Spooling: Print jobs are queued to be processed sequentially by a
printer.

 Data Structures and Algorithms


- Breadth-First Search (BFS): In graph algorithms, queues are used to
explore nodes level by level, making it essential for shortest path
algorithms.
- Event Simulation: Queues manage events in simulations, processing
them in the order they occur.

 Customer Service
- Call Center Management: Calls are queued until they can be answered
by an available operator, ensuring a first-come, first-served approach.
- Ticketing Systems: Customer service requests and ticket purchases are
handled in queues to maintain order.

Page | 9
 Manufacturing
- Job Scheduling: In assembly lines, tasks are queued for processing to
optimize workflow and resource allocation.
- Inventory Management: Products may be queued for restocking or
shipment based on demand.

 Gaming
- Player Matchmaking: Players are queued for matchmaking in
multiplayer games to ensure balanced teams.
- Event Handling: Game events (like player actions) are processed in the
order they occur using queues.

 Web Development
- Request Handling: Web servers manage incoming requests using
queues, allowing for orderly processing and load balancing.
- Task Scheduling in Background Jobs: Jobs such as sending emails or
processing data are queued to be executed asynchronously.

 Robotics
- Task Management: Robots can queue tasks that need to be completed,
ensuring they are handled in the correct sequence.

 Telecommunications
- Message Queuing: Messages are queued in systems like SMS or
messaging apps, ensuring they are delivered in the order they were sent.
Dated signature of Teacher
Marks Obtained

Process Product Total (50)


Related (35) Related (15)

Page | 10
Page | 11

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy