QUEUES IN DSA ALONG WITH CODE FOR BEGINNERS, Slides of Data Structures and Algorithms

The above uploaded documents covers the following topic in details..these are some verified and important lectures for those studnts or teachers who want to have some knwldge about the following topic along with pratice questions..IT CONTAIN code also for beginners and easy explanation

Typology: Slides

2021/2022

Available from 08/18/2022

SamenKhan
SamenKhan 🇵🇰

231 documents

1 / 44

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Science Department
Data Structures and Algorithms
Queues
Lecture 6
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c

Partial preview of the text

Download QUEUES IN DSA ALONG WITH CODE FOR BEGINNERS and more Slides Data Structures and Algorithms in PDF only on Docsity!

Data Structures and Algorithms

Queues

Lecture 6

Introduction to Queues

Introduction to Queues

Common Operations on Queues

- FRONT (Q ): Returns the first element on Queue Q. - ENQUEUE( x , Q ): Inserts element x at the end of Queue Q. - DEQUEUE( Q ): Deletes the first element of Q. - ISEMPTY( Q ): Returns true if and only if Q is an empty queue. - ISFULL(Q): Returns true if and only if Q is full.

Introduction to Queues (Uses)

Queue is most often used in a scenario where there is a shared resource that has to serve multiple requests but resource can handle only one request at a time

Queues Implementations

  • Static
    • Queue is implemented by an array, and size

of queue remains fix

  • Dynamic
    • A queue can be implemented as a linked

list , and expand or shrink with each enqueue

or dequeue operation.

Array Implementation of Queues

Array Implementation of Queues

How can we avoid to waste unused memory?

Circular Array?

Array Implementation of Queues

Linked List Implementation of

Queues

Linked List Implementation of

Queues

Use a pointer to store address of tail and call it rear

Linked List Implementation of

Queues

Static Implementation of Queues

Dynamic Implementation of

Queues

  • Dynamic implementation is done using

pointers.

  • FRONT: A pointer to the first element of the

queue.

  • REAR: A pointer to the last element of the

Front queue. x y z.

Rear