0% found this document useful (0 votes)
16 views72 pages

Data Structures: Queues & Linked Lists

Uploaded by

anamijames03
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views72 pages

Data Structures: Queues & Linked Lists

Uploaded by

anamijames03
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Data Structures and its

Application
Subject code: BCS304

01/05/2026 1
Dept of CSE
MODULE-2 ---TOPICS

Queues and Linked List


QUEUES:
2.1 Queues
2.2 Circular Queues
2.3 Using Dynamic Arrays
2.4 Multiple Stacks and queues.
LINKED LISTS :
2.5 Singly Linked
2.6 Lists and Chains
2.7 Representing Chains in C
2.8 Linked Stacks and Queues
2.9 Polynomials
2.10 Circular Linked List
01/05/2026 2
Dept of CSE
QUEUES:
Definition of Queue
Types of Queue
Representation of Queue
Queue Operations
Disadvantages of Queue

01/05/2026 3
Dept of CSE
Definition of Queue:
A queue is a special type of data structure (an ordered
collection of items) where elements are inserted from one
end and elements are deleted from the other end.
The end at which new elements are added is called
the rear and the end from which elements are deleted is
called the front.
Using this approach, the First element Inserted is the
First element to be deleted Out, and hence, queue is also
called First In First Out (FIFO) data structure.
01/05/2026 4
Dept of CSE
Representation of Queue: Queues can

be represented using following two data structures.

1. Array

2. Linked List
Sequential allocation: A queue can be implemented
using an array. It can organize a limited number of
elements.
Linked list allocation: A queue can be implemented
using a linked list. It can organize an unlimited number of
elements.
01/05/2026 5
Dept of CSE
Types of Queue: Since a queue elements

are stored in linear order, it can be implemented using

arrays and linked lists. Based on the method of

insertion and deletion the queues are classified

as shown below:

01/05/2026 6
Dept of CSE
Linear Queue ( Ordinary Queue)

01/05/2026 7
Dept of CSE
Operations performed on Queue

01/05/2026 8
Dept of CSE
Inserting Element into Queue

01/05/2026 9
Dept of CSE
C Function to Insert Element into Queue

01/05/2026 10
Dept of CSE
Delete item /element from Queue
Steps to check Queue is empty

If Queue is not empty then front will be less than rear so


increment front by one and delete the element from from end
using below function

01/05/2026 11
Dept of CSE
C Function Delete item /element from front end of Queue

01/05/2026 12
Dept of CSE
Display item /element from Queue
Step 1

Step 2

01/05/2026 13
Dept of CSE
C Function Display item /element from Queue

01/05/2026 14
Dept of CSE
Questions on Linear Queue

1. Define Queue?
2. Define Queue and List the Different types of Queue?
3. Define Queue? Mention the Operations performed on
Linear Queue?
4. Write a C Function to Insert(), Delete(),Display() into
Linear Queue?
5. Define Queue? List different tyes of Queue and State
the limitation of Ordinary Queue and Explain how do
you overcome the limitation by specifying the C
statements and Diagrammatic representation using
an example?

01/05/2026 15
Dept of CSE
Disadvantages of Linear Queue/Ordinary Queue

01/05/2026 16
Dept of CSE
Overcome Disadvantages of Linear Queue

01/05/2026 17
Dept of CSE
Overcome Disadvantages of Linear Queue

01/05/2026 18
Dept of CSE
Overcome Disadvantages of Linear Queue

01/05/2026 19
Dept of CSE
Overcome Disadvantages of Linear Queue

01/05/2026 20
Dept of CSE
Circular Queue
Definition: A Circular Queue is an extended version
of a normal queue where the last element of the
queue is connected to the first element of the queue
forming a circle.

21
01/05/2026
Dept of CSE
Example: Circular Queue

01/05/2026 22
Dept of CSE
01/05/2026 Dept of CSE 23
01/05/2026 Dept of CSE 24
01/05/2026 Dept of CSE 25
01/05/2026 Dept of CSE 26
01/05/2026 Dept of CSE 27
Function to insert into circular Queue

01/05/2026 Dept of CSE 28


Function to delete item from the front end of circular Queue

01/05/2026 Dept of CSE 29


Function to display items of circular Queue

01/05/2026 Dept of CSE 30


Questions on circular Queue

[Link] C functions to implement insertion, deletion,


display the operations of circular Queue [7 Marks]
2. What is the advantage of circular queue over ordinary
queue
Write the c program to simulate the working of circular
queue of integers using arrays provide the following
operations i. insert ii. Delete iii. display [8 Marks]
3. Write a C Function CQInsert() and CQDelete() on
circular
Queue [ 8 Marks]
4. A Circular queue the size of which is 5 has 3 elements
10,40,25, where F = 2 and R = 4. After inserting 50,60,
what
is the value of F and R? Trying to insert an element 30
at
01/05/2026 Dept of CSE 31
Dynamic Queue
Function to insert into circular queue dynamically

01/05/2026 Dept of CSE 32


Multiple Stacks and Queue

01/05/2026 Dept of CSE 33


Linked List

LINKED LIST:
Definition of Linked List
Representation of Linked List
Types of Linked List
Definition of Singly Linked List
Operations of Singly Linked List
Stacks using Linked List
Queues Using Linked List

01/05/2026 Dept of CSE 34


Linked List

01/05/2026 Dept of CSE 35


Types of Linked Lists and Singly Linked List

01/05/2026 Dept of CSE 36


Representing Chains in C

We need the following capabilities to make linked


representations possible:

1. A mechanism for dealing a node’s structure , that is the fields


it contains .we use self referential structures to do this
2. To create a new node we use MALLOC MACROS to do this
operation
3. To remove the node we make use of free function to handle
this operation

01/05/2026 Dept of CSE 37


Self Referential Structure

01/05/2026 Dept of CSE 38


How to define self Referential Structure

01/05/2026 Dept of CSE 39


How to create an Empty List

01/05/2026 Dept of CSE 40


How to create node of a linked list

01/05/2026 Dept of CSE 41


How to delete node of a linked list

01/05/2026 Dept of CSE 42


Operations that can be performed on Singly Linked list

01/05/2026 Dept of CSE 43


Insert a node at the front end of the list

01/05/2026 Dept of CSE 44


How to find the last node

How to find the address of last node

01/05/2026 Dept of CSE 45


Display the content of Linked List

01/05/2026 Dept of CSE 46


Delete a node from front end of Linked List

01/05/2026 Dept of CSE 47


Insert a node at the rear end of Linked List

01/05/2026 Dept of CSE 48


Delete a node from the rear end of Linked List

01/05/2026 Dept of CSE 49


Questions on Singly Linked List

1. Write/Develop a C Functions to perform the following


operations on singly linked list
i. Insert item at the front end
ii. Insert item at the rear end
iii. Delete item at the front end
iv Delete item at the rear end
v. Display the contents of the singly linked list [12
Marks]

01/05/2026 Dept of CSE 50


Implementing Stacks using linked list

01/05/2026 Dept of CSE 51


Implementing Queue using linked list

01/05/2026 Dept of CSE 52


Circular Singly Linked List

01/05/2026 Dept of CSE 53


First Node and Last Node

01/05/2026 Dept of CSE 54


Empty Circular Linked list

01/05/2026 Dept of CSE 55


Only One Node Circular Linked list

01/05/2026 Dept of CSE 56


Operations on Circular Linked list

01/05/2026 Dept of CSE 57


Insert at Front end in Circular Linked list

01/05/2026 Dept of CSE 58


Insert at Rear end in Circular Linked list

01/05/2026 Dept of CSE 59


Delete item at Front end in Circular Linked list

01/05/2026 Dept of CSE 60


Delete item at rear end in Circular Linked list

01/05/2026 Dept of CSE 61


Display items in Circular Linked list

01/05/2026 Dept of CSE 62


Questions on Circular Singly Linked List

1. Write/Develop a C Functions to perform the following


operations on Circular singly linked list
i. Insert item at the front end
ii. Insert item at the rear end
iii. Delete item at the front end
iv Delete item at the rear end
v. Display the contents of the singly linked list [12
Marks]
2. Mention the advantages of Circular Singly linked List
[ 3 Marks]

01/05/2026 Dept of CSE 63


Polynomials- Representation using linked list

01/05/2026 Dept of CSE 64


Polynomials

01/05/2026 Dept of CSE 65


Polynomials

01/05/2026 Dept of CSE 66


Insert the term of polynomial at rear end

01/05/2026 Dept of CSE 67


How to read the polynomial with n terms

01/05/2026 Dept of CSE 68


How to Display the polynomial

01/05/2026 Dept of CSE 69


How to Evaluate the polynomial

01/05/2026 Dept of CSE 70


Program to evaluate the polynomial

01/05/2026 Dept of CSE 71


01/05/2026 Dept of CSE 72

You might also like