Queue Reviewer -Data Structure and Algorithm

0.0(0)
studied byStudied by 1 person
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

21 Terms

1
New cards

Queue

This is an abstract data structure, somewhat similar to stacks. Unlike stacks, a _____ is open at both its ends.

2
New cards

enqueue()

add (store) an item to the queue

3
New cards

dequeue()

remove (access) an item from the queue.

4
New cards

peek()

Gets the element at the front of the queue without removing it.

5
New cards

isfull()

checks if the queue is full

6
New cards

isemtpy()

checks if the queue is empty

7
New cards

Implementation of peek() function in C programing language

int peek () {

return queue [front];

}

8
New cards

Implementation of isfull() function in C programing language

bool isfull () {

if (rear = MAXSIZE - 1)

return true;

else return false;

}

9
New cards

isempty()

bool isempty() {

in (front < 0 || front > rear)

else

return false;

}

10
New cards

Enqueue Operation

• Step 1 − Check if the queue is full.

• Step 2 − If the queue is full, produce overflow error and exit.

• Step 3 − If the queue is not full, increment rear pointer to point the next empty space.

• Step 4 − Add data element to the queue location, where the rear is pointing.

• Step 5 − Return success.

11
New cards

Implementation of enqueue() in C programming language

int enqueue ( int data)

if (is full())

return 0;

rear = rear + 1;

queue [rear] = data;

return 1;

12
New cards

Dequeue Operation

• Step 1 − Check if the queue is empty.

• Step 2 − If the queue is empty, produce underflow error and exit.

• Step 3 − If the queue is not empty, access the data where front is pointing.

• Step 4 − Increment front pointer to point to the next available data element.

• Step 5 − Return success.

13
New cards

Implementation of dequeue() in C programming language

int dequeue() {

if (isempty())

return 0;

int data = queue[front];

front = front + 1;

return data;

}

14
New cards
  • Simple Queue,

  • Double-Ended Queue (Dequeue)

  • Circular Queue

  • Priority Queue

Different type of queues

15
New cards

Simple Queue

Simply follows FIFO Structure. We can only insert the element at the back and remove the element from the front of the queue.

16
New cards

Double-Ended Queue (Dequeue)

In a double-ended queue the insertion and deletion operations, both can be performed from both ends.

17
New cards

Input Restricted Queue

This is a simple queue. In this type of queue, the input can be taken from only one end but deletion can be done from any of the ends

18
New cards

Output Restricted Queue

This is also a simple queue. In this type of queue, the input can be taken from both ends but deletion can be done from only one end.

19
New cards
  • Task Scheduling in operating systems

  • Data Transfer in Network Communication

  • Simulation of real-world system (e.g., waiting lines)

  • Priority queues for event processing queues for event processing.

Applications of Queue

20
New cards
  • A large amount of data can be managed efficiently with ease.

  • Operations such as insertion and deletion can be performed with ease as it follows the first in first out rule.

  • Queues are useful when a particular service is used by multiple consumers.

  • Queues are fast in speed for data inter-process communication.

  • Queues can be used in the implementation of other data structures.

Advantages of queue data structure

21
New cards
  • The operations such as insertion and deletion of elements from the middle are time consuming.

  • Maximum size of a queue must be defined prior in case of array implementation

Disadvantages of Queue Data Structure