DS Lab 3
DS Lab 3
3 - Part A
Aim: Write a C language program for Linear queue operations insert, delete and display.
Requirements: Knowledge of Array.
Outcome: Understand the data structure concept with implementation knowledge of linear
queue.
Theory:
People moving on an escalator. The people who got on the escalator first will be the
first one to step out of it.
People waiting for a bus. The first person standing in the line will be the first one to get
into the bus.
People standing outside the ticketing window of a cinema hall. The first person in the
line will get the ticket first and thus will be the first one to move out of it.
Luggage kept on conveyor belts. The bag which was placed first will be the first to
come out at the other end.
Cars lined at a toll bridge. The first car to reach the bridge will be the first to leave.
In all these examples, we see that the element at the first position is served first. Same is the
case with queue data structure. A queue is a FIFO (First-In, First-Out) data structure in which
the element that is inserted first is the first one to be taken out. The elements in a queue are
added at one end called the REAR and removed from the other end called the FRONT. Queues
can be implemented by using either arrays or linked lists.
Queues can be easily represented using linear arrays. As stated earlier, every queue has front
and rear variables that point to the position from where deletions and insertions can be done,
respectively. The array representation of a queue is shown in Fig
Instructions:
1. Follow the algorithm steps and write a C language program for linear queue
implementation and perform insertion, deletion and display operations.
Exp. 3 - Part -B
Program:
Output:
Observation & Learning:
Questions:
1. What are the drawbacks of linear queue?
2. Differentiate between stack and queue?