انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Lecture 4:: simple Queue and circular Queue

الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 2
أستاذ المادة اسراء عبد الله حسين علي الدليمي       09/04/2017 13:48:37
Queues are data structures that follow the First In First Out (FIFO) i.e. the first element that is added to the queue is the first one to be removed.
In a queue data structure, the insertion operation is performed using a function called enqueue( based on index rear)and deletion operation is performed using a function called dequeue(based on index front).
As in stacks, a queue can also be implemented using Arrays, Linked-lists. For the sake of simplicity, we shall implement queues using one-dimensional array.
There are two types of queue: Simple And Circular queue.

Algorithm 1: enqueue
Inputs: Q: array as integer, f: front pointer, r: rear pointer, n: size of queue, x: the new element
Outputs: insert x to Q.
Begin
If ( r = n-1 ) then
Write ("Queue is over flow")
Else
r = r + 1
Q[r]=x
If ( f = -1) then
F=0
End



Example 1:: Suppose a queue with size 5 do the following ::
1- Insert the elements (25, 30, 51, 60 and 85)

25 30 51 60 85





2- Perform the dequeue for three times
60 85



Example 2::What the operation that perform on (a) to obtain (b)


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .