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

1.3.1 (Enqueue) New

This document discusses queues and the enqueue operation. It defines enqueue as adding an element to the rear of a queue. The steps of enqueue are outlined as checking if the queue is full, incrementing the rear pointer if not full, adding the data element, and returning success. Figures demonstrate how enqueue works by adding an element to the rear and updating the pointers. The algorithm for enqueue is presented, and key concepts about queues like FIFO and applications are summarized.

Uploaded by

lunabrown2004
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 views8 pages

1.3.1 (Enqueue) New

This document discusses queues and the enqueue operation. It defines enqueue as adding an element to the rear of a queue. The steps of enqueue are outlined as checking if the queue is full, incrementing the rear pointer if not full, adding the data element, and returning success. Figures demonstrate how enqueue works by adding an element to the rear and updating the pointers. The algorithm for enqueue is presented, and key concepts about queues like FIFO and applications are summarized.

Uploaded by

lunabrown2004
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
You are on page 1/ 8

University of Computer Studies

Chapter 2: Linear Data Structure (Enqueue)

Dr. Nwe Nwe Soe

Professor

Faculty of Computer Science

Data Structures and Algorithms

University of Computer Studies, FCS 1


Lecture Objectives FCS

• To complete the formal specification of the Queue

• To identify and address any exceptional situations and determine boundedness.

University of Computer Studies, FCS 2


Enqueue Operation FCS
Queue Operations and Specifications

Enqueue - adds an element to the rear of a queue

• 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


Figure 1: Operations in Queue
point the next empty space.

• Step 4 − Add data element to the queue location, where the

rear is pointing.

• Step 5 − return success.


University of Computer Studies, FCS 3
Enqueue Operation FCS

Rear Front
D

C B A Before

Rear Front

D C B A After

Figure 2: Operation in Enqueue

University of Computer Studies, FCS 4


Algorithm Of Enqueue FCS
procedure enqueue(data)
if queue is full
return overflow
rear ← rear + 1
queue[rear] ← data
return true
end procedure

int enqueue (int data)


if(isfull())
return 0;
rear = rear + 1;
queue[rear] = data;
return 1;
end procedure
University of Computer Studies, FCS 5
Lecture Summary FCS

• Firt Ins First Out (FIFO) data structure Implemented as array or linked listLinked

lists: queue

• Add or Store in Queue called “Enqueue”

• Application in Queue

University of Computer Studies, FCS 6


Learning Outcomes FCS

After completing this course satisfactorily, a student will be able to:

1. A list structure with two access points called the front and rear.

2. All insertions (Enqueue) occur at the rear .

3. Varying length (dynamic).

4. Homogeneous components

5. Has a First-In, First-Out characteristic (FIFO)

University of Computer Studies, FCS 7


References FCS

1. “Data Structures and Algorithms: Annotated Reference with Examples”, (1st Edition, 2008
by Granville Barnett and Luca Del Tongo)
2. Lecture Notes for Data Structures and Algorithms (Version of 27 March 2019) by John
Bullinaria, School of Computer Science University of Birmingham , UK
3. https://CS1020 Data Structures and Algorithms I Lecture Note #9 Stacks and Queues Two
basic linear data structures. - ppt download (slideplayer.com)
[Slide 4]

8
Faculty of Computer Science, University of Computer Studies

You might also like