Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit1 DS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 88

DATA STRUCTURE

INTRODUCTION TO
DATA STRCTURE
Unit-1
COURSE OUTCOMES:
Upon successful completion of this course, students will be able to:
— CO1: Analyze and design of linear data structure such as Queue and
Stack for solving problems.

— CO2: Analyze and design of linear data structure such as Linked List
for solving problems.

— CO3: Analyze and design of non-linear data structure such as Tree for
solving problems.

— CO4: Analyze and design of non-linear data structure such as Graph


for solving problems.

— CO5: Use different sorting and searching mechanisms by analyzing


suitability.
Syllabus – Unit 1
— Introduction to Data structure:
— Introduction, Abstract data types with example (Types:
Primitive, Non primitive, Linear, Nonlinear, Static, Dynamic
Data structures). Stack: Fundamentals of stack,
representation using array, Applications of stack: Recursion,
Expression conversions and evaluations etc., Queue:
Fundamentals of queue, representation using array, Circular
queues, Double ended queues concepts and operations,
Applications of queue to solve problems.

— Self-Study: 3-Tuple representation of sparse matrix, Sparse


Matrix: Addition and Fast transpose, Priority Queue.
Basic Concepts:

Data:
Any raw fact or figure is called as data.

Information:
The processed data is called as information.

Structure:
Representation of data is called as structure.
Abstract data types(ADT)
Ø ADT, is a logical description of how we view the data
and the operations that are allowed without regard to
how they will be implemented. .
Ø An ADT specifies what each operation does, but not
how it does it.
Ø The ADT can be implemented using one of many
different data structure(primitive) like;
stack
queue
list etc.
Data Structure

Ø A data structure is a specialized format for organizing,


processing, retrieving and storing data.

Ø The logical or mathematical model of a particular


organization of data is called data structure.

Ø Data Structure can be defined as the group of data elements


which provides an efficient way of storing and organizing
data in the computer so that it can be used efficiently.
Queues for ticket Stack of Books Stack of Plates Stack of CDs
Types of Data Structure
— Primitive data structure
Primitive data structure is a data structure that can
hold a single value in a specific location.
examples : float, character, integer and pointer.

— Non-primitive data structure


The non-primitive data structure is a kind of data
structure that can hold multiple values either in a
contiguous or random location.
examples : linear and non linear.
Linear Data structure

Ø A data structure is said to be linear if its elements combine


to form any specific order.

ØA data structure is called linear if all of its elements are


arranged in the linear order.

Ø In linear data structures, the elements are stored in non-


hierarchical way where each element has the successors
and predecessors except the first and last element.
Array
• An array is a linear data structure that collects elements of
the same data type and stores them in contiguous and
adjacent memory locations.

• The data type of the element may be any valid data type
like char, int, float or double.

• The elements of array share the same variable name but


each one carries a different index number known as
subscript.


Linked List

— A node contains two fields i.e., data stored at that particular address
and the pointer which contains the address of the next node in the
memory.

— Linked list is a linear data structure which is used to maintain a list in


the memory. It can be seen as the collection of nodes stored at non-
contiguous memory locations. Each node of the list contains a pointer
to its adjacent node.
Stack
— Stack is a data structure in which insertion and deletion
operations are performed at one end only, called TOP.

— The insertion operation is referred to as ‘PUSH’ and


deletion is referred as ‘POP’ operation.

— Stack is also called as Last In First Out (LIFO) data structure.


Queue
— The data structure which permits the insertion at one and
deletion at another end, known as Queue.

— End at which deletion is occurs is known as FRONT end and


another end at which insertion occurs is known as REAR
end.

— Queue is also called as First In First Out (FIFO) .


Non linear Data structure
Ø This structure is mostly used for representing data that
contains a hierarchical relationship among various
elements.

Ø This data structure does not form a sequence i.e., each


item or element is connected with two or more other
items in a non-linear arrangement. The data elements are
not arranged in sequential structure.

Ø Example :
q Tree
qGraph
Tree

— A Tree can be define as finite data items (nodes) in which


data items are arranged in branches and sub branches.
— Tree represent the hierarchical relationship between
various elements.
— Tree consist of nodes connected by edge, the represented
by circle and edge lives connecting to circle.
Graph

— Graphs can be defined as the pictorial representation of


the set of elements (represented by vertices) connected by
the links known as edges.

— A graph is different from tree in the sense that a graph can


have cycle while the tree can not have the one.
Static data structure

Ø In static data structures, the size of the data structure is fixed.


Ø The size of the structure has to be specified at the time of
initialization, and it cannot be changed later. However, we can modify
the content of the data structure without modifying the memory
allocated to it.
Ø Example: Arrays

Dynamic data structure

Ø In dynamic data structures, the size of the data structure can be


modified after initialization.
Ø It means we can add/delete elements from the data structure, thus
modifying its size at runtime. Dynamic data structures are memory
efficient and especially useful when we don't know the data size
beforehand.
Ø Example: Linked list
Operations on Data structure

The possible operations on the linear data structure are:

1.Traversal 4.Searching
2.Insertion 5.Sorting
3.Deletion 6.Merging.
Operations On Data structure
1) Traversing: Every data structure contains the set of data
elements. Traversing the data structure means visiting each
element of the data structure in order to perform some
specific operation like searching or sorting.

2) Insertion: Insertion can be defined as the process of


adding the elements to the data structure at any location.

3) Deletion: The process of removing an element from the


data structure is called Deletion. We can delete an element
from the data structure at any random location.
Operations On Data structure
4) Searching: The process of finding the location of an
element within the data structure is called Searching. There
are two algorithms to perform searching, Linear Search and
Binary Search.

5) Sorting: The process of arranging the data structure in a


specific order is known as Sorting. There are many algorithms
that can be used to perform sorting.

6) Merging: When two lists List A and List B of size M and N


respectively, of similar type of elements, clubbed or joined to
produce the third list, List C of size (M+N), then this process
is called merging.
Advantages of Data structure
• It helps in efficient storage of data in the storage device.
• Data structure provides effective and efficient processing
of small as well as large amount of data.
• Usage of proper data structure, can help programmer save
lots of time or processing time while operations such as
storage, retrieval or processing of data.
• Most of the well organized data structures like Array, stack,
queues, graph, tree, linked list has well built and pre-
planned approach for operations like storage, addition,
retrieval, manipulation, deletion, etc. While using them,
programmer can be completely rely on these data
structures.
• Data structure usage can simply encourage reusability in
long run as well.
ARRAY
"We have a list of 1000 students' marks of an integer
type. If using the basic data type (int), we will declare
something like the following…"

int main()
{

int studMark0, studMark1, studMark2, ...,


studMark999;

Return 0;

}
By using an array, we just declare like this,
int studMark[1000];

It will reserve 1000 contiguous memory locations for storing


the students’ marks.
Types of Arrays
One Dimensional Array
A collections of data elements given by one variable name
using only one subscript
Declaration:
data_type Array_name[size]

data_type : valid data type like int, float or char


Arrayname : valid identifier
size : maximum number of elements that can be
stored in array .
Example:
int arr[5];
Ø Element − Each item stored in an array is called an
element.
Ø Index −Each location of an element in an array has a
numerical index, which is used to identify the element.
Ø Where int specifies the data type or type of elements
arrays stores. “arr” is the name of array & the number
specified inside the square brackets is the number of
elements an array can store, this is also called size or
length of array.
Memory Representation of an Array

1000 1002 1004 1006 1008

Address of the ith element(Address(A[i]))=B+w*(i-LB)

where B=Base address of the array A

w=Size of the each element

LB =Lower index of the array


TWO DIMENSIONAL ARRAY
Ø There could be situations where a table of values will have to be stored.

Name/Marks Science Maths English

Ramesh 45 48 42
Gopal 48 44 44
Sita 20 14 2

Ø C allows us to define such tables of items by using two-


dimensional arrays.
Ø The two dimensional array are declared as follows

type array_name[row_size][column_size];
TWO DIMENSIONAL ARRAY

int MyArray[3][3];

0,0 0,1 0,2


1,0 1,1 1,2
2,0 2,1 2,2

0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2


Memory Representation of Matrix

Matrices are stored in contiguous memory


locations.

The matrices are stored in the computer memory


in two different representations:

— Row-major Order Representation


— Column-major Order Representation
Address calculation of Matrix Elements in
Memory
Row-major Order Representation:

A[r][c] is a matrix
where r=Row size(ranges from 0 to r-1)
c=Column size(ranges from 0 to c-1)
B=base address of the array A

Address(A[i][j])=B+(i*c + j) *w

where w=size of each element


Address calculation of Matrix Elements in
Memory
Column-major Order Representation:

A[r][c] is a matrix
where r=Row size(ranges from 0 to R-1)
c=Column size(ranges from 0 to C-1)
B=base address of the array A

Address(A[i][j])=B+(j*r + i) *w

where w=size of each element


Basic operations of an Array
• Traversal - This operation is used to print the
elements of the array.
• Insertion - It is used to add an element at a
particular index (Beginning, end, at any position).
• Deletion - It is used to delete an element from a
particular index.
• Search - It is used to search an element using the
given index or by the value.
• Update - It updates an element at a particular
index.
Insertion Operations

§ Insertion operation is to insert one or more data


elements into an array.

§ Based on the requirement, a new element can be


added at the beginning, end, or any given index of
array.

§ Here, we see a practical implementation of


insertion operation, where we add data at the end
of the array.
Insertion Algorithm
Let LA be a Linear Array (unordered) with N elements and K
is a positive integer such that K<=N.
Following is the algorithm where ITEM is inserted into the
Kth position of LA.
1. Start
2. Set J = N
3. Set N = N+1
4. Repeat steps 5 and 6 while J >= K
5. Set LA[J+1] = LA[J]
6. Set J = J-1
7. Set LA[K] = ITEM
8. Stop.
Deletion Operations
Deletion refers to removing an existing element from the array and re-
organizing all elements of an array.

Algorithm:
Consider LA is a linear array with N elements and K is a positive integer
such that K<=N. Following is the algorithm to delete an element
available at the Kth position of LA.

1. Start
2. Set J = K
3. Repeat steps 4 and 5 while J < N
4. Set LA[J] = LA[J + 1]
5. Set J = J+1
6. Set N = N-1
7. Stop
Search Operations
We can perform a search for an array element based on its
value or its index.
Algorithm :
Consider LA is a linear array with N elements and K is a
positive integer such that K<=N. Following is the algorithm
to find an element with a value of ITEM using sequential
search.
1. Start
2. Set J = 0
3. Repeat steps 4 and 5 while J < N
4. IF LA[J] is equal ITEM THEN GOTO STEP 6
5. Set J = J +1
6. PRINT J, ITEM
7. Stop
Update Operations
Update operation refers to updating an existing element
from the array at a given index.
Algorithm
Consider LA is a linear array with N elements and K is a
positive integer such that K<=N. Following is the algorithm
to update an element available at the kth position of LA.

1. Start
2. Set LA[K-1] = ITEM
3. Stop
v Fundamentals of Stack.
v Representation using Array.
v Operations on Stack
PUSH Operation
POP Operation
stack PEEP Operation
v Applications of stack:
Recursion
Expression Conversions
and Evaluations etc.
Stack: A Last-in First-out (LIFO) List
A stack is a data structure in which data is
added and removed at only one end called the
top.

To add (push) an item to the stack, it must be


placed on the top of the stack.

To remove (pop) an item from the stack, it


must be removed from the top of the stack
too.

Thus, the last element that is pushed into the


stack, is the first element to be popped out of
the stack.
Operations on Stack
Ø push() − inserting an element into the stack.
Ø pop() − Removing an element from the stack.
Ø To use a stack efficiently, we need to check the
status of stack as well. For the same purpose, the
following functionality is added to stacks −
Ø peek() − get the top data element of the stack,
without removing it.
Ø isFull() − check if stack is full.
Ø isEmpty() − check if stack is empty.
Ø display(): It prints all the elements available in the
stack.
Push operation
START

Is
top=MAX-
1
?
PUSH
Enter an element to be
inserted

top
Set top=top+1
Print “Stack
Overflow” top
Set stack [Top]
=Item

STOP
PUSH Operation Algorithm
ALGORITHM:
PUSH (STACK, TOP, MAX_SIZE, ITEM)
Input: STACK is the linear array with maximum size
MAX_SIZE.
Output: This algorithm pushes (or inserts) an
element ITEM on to the STACK.
Step 1: If TOP=MAX_SIZE-1, then
Print “Stack Overflow” and exit.
Step 2: Set TOP=TOP+1
Step 3: Set STACK [TOP] =ITEM
Step 4: Exit
Pop Operation

POP

top

top
POP Operation Algorithm
ALGORITHM: POP (STACK, TOP, MAX_SIZE, ITEM)
Input: STACK is the linear array with maximum size
MAX_SIZE.
Output: This algorithm deletes the top element of the STACK
and assigns it to the variable ITEM.
Step 1: If TOP=-1, then
Print “Stack Underflow” and exit.
Step 2: Set ITEM=STACK [TOP]
Step 3: Set TOP=TOP-1
Step 4: Exit
PEEP Operation Algorithm
ALGORITHM:PEEP (STACK, TOP, MAX_SIZE, ITEM)
Input: STACK is the linear array with maximum size
MAX_SIZE.
Output: This algorithm returns the top most
element of the STACK.
Step 1: If TOP=-1, then
Print “Stack is empty” and exit.
Step 2: Return STACK [TOP]
Step 3: Exit
Application Of Stack

1. Conversion of Infix expression to equivalent Postfix


Expression
2. Evaluation of Postfix Expression
3. Conversion of Infix expression to equivalent Prefix
Expression
4. Evaluation of Prefix Expression
5. Recursion: The recursion means that the function is
calling itself again. To maintain the previous states,
the compiler creates a system stack in which all the
previous records of the function are maintained.
Infix Notation
éInfix notation is the common arithmetic and

logical formula notation, in which operators are

written infix-style between the operands they act

on

Ex: A + B
Prefix Notation
• In Prefix notation, the operator comes before the

operand.

• The Infix expression A+B will be written as +AB in

its Prefix Notation.

• Prefix is also called ‘Polish Notation’


Postfix Notation

• In Postfix notation, the operator comes after the

Operand.

• The Infix expression A+B will be written as AB+ in its

Postfix Notation.

• Postfix is also called ‘Reverse Polish Notation’


Examples of infix to prefix and postfix

Infix PostFix Prefix

A+B AB+ +AB

(A+B) * (C + D) AB+CD+* *+AB+CD

A-B/(C*D^E) ABCDE^*/- -A/B*C^DE


CONVERSION OF INFIX TO POSTFIX
EXPRESSION
ALGORITHM: INFIX_TO_POSTFIX (I, P)
Input: I is an arithmetic expression written in infix notation.
Output: This algorithm converts the infix expression to its
equivalent postfix expression P.

Step 1: Add ‘)’ to the end of the infix expression I and push
‘(‘on to the STACK.
Step 2: Scan I from left to right and repeat Step 3 to Step 6 for
each element of I until the STACK is empty.
Step 3: If an operand is encountered, add it to P.
Step 4: If a left parentheses ‘(‘is encountered, push it on to the
STACK.
Contd…
Step 5: If an operator OP is encountered, then
(a)Repeatedly pop from the STACK and add each operator
(on the top of the STACK) to the Postfix expression ‘P’ which has
same precedence as or higher precedence than OP.
(b)Push the operator OP on to the STACK.
[End of if]
Step 6: If a right parentheses ‘)’ is encountered, then
(a) Repeatedly pop from the STACK and add each operator
on the top of the STACK) to the Postfix expression ‘P’ until a left
parentheses ‘(‘ is encountered.
(b) Remove the left parentheses ‘(‘. [Don’t add it to the
postfix expression P.]
[End of if]
[End of Step 2 loop]
Step 7: Exit
Evaluation of Postfix Expression
ALGORITHM: EVALUATE_POSTFIX (P)
Input: P is an arithmetic expression in postfix notation.
Output: This algorithm evaluates the postfix expression P and assigns the result to the variable
VALUE.

Step 1: Add right parentheses ‘)’ to the end of P.


Step 2: Scan P from left to right and repeat Step 3 to Step 4 for each element of P until the ‘)’ is
encountered.
Step 3: If an operand is encountered, push it on to the STACK.
Step 4: If an operator OP is encountered, then
(a)Pop the two top elements of the STACK, where A is the top element and
B is the next to top element.
(b)Evaluate B OP A.
(c)Push the result of the evaluation on to the STACK.
[End of If]
[End of Step 2 loop]
Step 5: Set VALUE equal to the top most element of the STACK.
Step 6: EXIT
Recursion
When a function or module call itself. This technique is
known as recursion. In recursion, a function α either
calls itself directly or
calls a function β that in turn calls the original
function α. The function α is called
recursive function.
Example − a function calling itself.
int function(int value) {
if(value < 1)
return;
function(value - 1);
printf("%d ",value);
}
v Fundamentals of queue.
v Representation using array.
v Circular queues.
Queue v Double ended queues concepts and
operations.
v Applications of queue to solve
problems.
Introduction to Queue
Ø Queue is the data structure that is similar to the queue in the
real world.

Ø A queue can be defined as an ordered list which enables insert


operations to be performed at one end called REAR and delete
operations to be performed at another end called FRONT.

Ø Queue works on the principle of First-In-First-Out (FIFO),the


element that has been added first to the list will be the element
that will be removed first from the list.

Ø For example, people waiting in line for a rail ticket form a


queue.
MODELS OF QUEUE
Simple Queue or Linear Queue
— In Linear Queue, an insertion takes place from one end while the
deletion occurs from another end. The end at which the insertion
takes place is known as the rear end, and the end at which the
deletion takes place is known as front end. It strictly follows the FIFO
rule.

— The major drawback of using a linear Queue is that insertion is done


only from the rear end. If the first three elements are deleted from the
Queue, we cannot insert more elements even though the space is
available in a Linear Queue. In this case, the linear Queue shows the
overflow condition as the rear is pointing to the last element of the
Queue.
Insertion(ENQUEUE) Operation
ALGORITHM: Q_INSERT(QUEUE,MAX,FRONT,REAR, ITEM)
Input: QUEUE is the linear array with maximum size MAX.FRONT and REAR are
the pointer variables pointing to Front end and Rear end.

Output: This algorithm inserts an element ITEM on to the QUEUE.

Step 1: If REAR=MAX-1, then


Print “Queue Overflow” and Exit.
Step 2: If FRONT=-1 and REAR=-1,then Set FRONT=0 and REAR=0
Else
Set REAR=REAR+1
Step 3: [Insert an element in to the Queue]
Set QUEUE[REAR]=ITEM
Step 4: Exit
Deletion(DEQUEUE) Operation
ALGORITHM: Q_DELETE(QUEUE,MAX,FRONT,REAR, ITEM)
Input: QUEUE is the linear array with maximum size MAX.FRONT and REAR are
the pointer variables pointing to Front end and Rear end respectively.
Output: This algorithm deletes an element from the QUEUE and stores it in the
variable ITEM.

Step 1: If FRONT=-1 and REAR=-1, then


Print “Queue Underflow” and Exit.
Step 2: [Delete an element from the Queue]
Set ITEM=QUEUE[FRONT]
Step 3: If FRONT= REAR , then
Set FRONT=-1 and REAR=-1
Else
Set FRONT=FRONT+1
Step 4: Exit
Circular Queue

— A queue, in which the last node is connected back to the first node to
form a cycle, is called as circular queue.
— Circular queue are the queues implemented in circular form rather
than in a straight line.
— It is similar to the linear Queue except that the last element of the
queue is connected to the first element. It is also known as Ring Buffer,
as all the ends are connected to another end.
— Circular queues overcome the problem of unutilized space in linear
queue implemented as an array.
— The main disadvantage of linear queue using array is that when
elements are deleted from the queue, new elements cannot be added
in their place in the queue, i.e. the position cannot be reused.
Insertion (ENQUEUE) Operation
ALGORITHM: C_Q_INSERT(C_QUEUE,MAX,FRONT,REAR, ITEM)
Input: C_QUEUE is the Circular Queue with maximum size MAX.FRONT and REAR
are the pointer variables pointing to Front end and Rear end respectively.
Output: This algorithm inserts an element ITEM on to the circular queue
C_QUEUE.

Step 1: If FRONT=(REAR+1) , or Front==0&& Rear=Max-1 then


Print “Circular Queue Overflow” and Exit.
Step 2: If FRONT=-1 and REAR=-1,then
Set FRONT=0 and REAR=0
Else Rear=Max-1 & front!=0
Set Rear =0
Else set Rear=Rear+1
Step 3: [Insert an element in to the Queue]
Set C_QUEUE[REAR]=ITEM
Step 4: Exit
Deletion(DEQUEUE) Operation
ALGORITHM: C_Q_DELETE(C_QUEUE,MAX,FRONT,REAR, ITEM)

Input: C_QUEUE is the Circular Queue with maximum size MAX. FRONT and
REAR are the pointer variables pointing to Front end and Rear end
respectively.
Output: This algorithm deletes an element from the Circular Queue C_QUEUE
and stores it in the variable ITEM.

Step 1: If FRONT=-1
Print “Circular Queue Underflow” and Exit.
Step 2: [Delete an element from the Queue]
Set ITEM=C_QUEUE[FRONT]
Step 3: If FRONT= REAR , then
Set FRONT=-1 and REAR=-1
Else
Set FRONT=MAX-1
set FRONT=0
Else
set FRONT=FRONT+1
Step 4: Exit
DOUBLE ENDED QUEUE(DEQUE)

— In Deque or Double Ended Queue, insertion and deletion can be


done from both ends of the queue either from the front or rear.
— we can insert and delete elements from both front and rear ends
of the queue.
— Deque can be considered as stack because stack follows the LIFO
(Last In First Out) principle in which insertion and deletion both
can be performed only from one end. And in deque, it is possible
to perform both insertion and deletion from one end, and Deque
does not follow the FIFO principle.
— Deque can be used as a palindrome checker means that if we
read the string from both ends, then the string would be the
same.
Double Ended QUEUE(DEQUE)
— Input Restricted Dequeue
— Allows insertion at only one end(rear) of the list

— Allows deletion at the both front and rear ends.

— Output Restricted Dequeue


— Allows deletion at only one end(front) of the list

— Allows insertion at the both front and rear ends


Insertion at the front end
In this operation, the element is inserted from the front end
of the queue.

Before implementing the operation, we first have to check


whether the queue is full or not. If the queue is not full, then
the element can be inserted from the front end by using the
below conditions –

• If the queue is empty, both rear and front are initialized


with 0. Now, both will point to the first element.

• Otherwise, check the position of the front if the front is


less than 1 (front < 1), then reinitialize it by front = n - 1,
i.e., the last index of the array.
Insertion at the front end
Insertion at the rear end
In this operation, the element is inserted from the rear end of the
queue.
Before implementing the operation, we first have to check again
whether the queue is full or not. If the queue is not full, then the
element can be inserted from the rear end by using the below
conditions –

• If the queue is empty, both rear and front are initialized with 0.
Now, both will point to the first element.

• Otherwise, increment the rear by 1. If the rear is at last index (or


size - 1), then instead of increasing it by 1, we have to make it
equal to 0.
Insertion at the rear end
Deletion at the front end
— In this operation, the element is deleted from the front
end of the queue. Before implementing the operation, we
first have to check whether the queue is empty or not.
— If the queue is empty, i.e., front = -1, it is the underflow
condition, and we cannot perform the deletion. If the
queue is not full, then the element can be inserted from
the front end by using the below conditions –

— If the deque has only one element, set rear = -1 and front =
-1.
— Else if front is at end (that means front = size - 1), set front
= 0.
— Else increment the front by 1, (i.e., front = front + 1).
Deletion at the front end
Deletion at the rear end
— In this operation, the element is deleted from the rear
end of the queue. Before implementing the operation,
we first have to check whether the queue is empty or
not.
— If the queue is empty, i.e., front = -1, it is the
underflow condition, and we cannot perform the
deletion.

— If the deque has only one element, set rear = -1 and


front = -1.
— If rear = 0 (rear is at front), then set rear = n - 1.
— Else, decrement the rear by 1 (or, rear = rear -1).
Deletion at the rear end
Uses of Queue
— Simulation of Traffic Control System
— Implementation of CPU Scheduling Algorithms
— Round Robin Scheduling Algorithm
— Multilevel Queue Scheduling Algorithm
— Multilevel Feedback Queue Scheduling Algorithm
— Areas of Customer Services(Railway Reservation)
— Memory Management.
— Trees traversing.
Application Of Queue
1. Queues are widely used as waiting lists for a single shared
resource like printer, disk, CPU.
2. Queues are used in asynchronous transfer of data (where
data is not being transferred at the same rate between two
processes) for eg. pipes, file IO, sockets.
3. Queues are used as buffers in most of the applications like
MP3 media player, CD player, etc.
4. Queue are used to maintain the play list in media players in
order to add and remove the songs from the play-list.
5. Queues are used in operating systems for handling
interrupts.

You might also like