Presentation is loading. Please wait.

Presentation is loading. Please wait.

Presented By: Mahmoud Rafeek Alfarra

Similar presentations


Presentation on theme: "Presented By: Mahmoud Rafeek Alfarra"— Presentation transcript:

1 Presented By: Mahmoud Rafeek Alfarra
MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Data structure Using C# Information Technology , 3’rd Semester Lecture 12: Operations of Queue Presented By: Mahmoud Rafeek Alfarra

2 Outline Implementing the enqueue Implementing the dequeue
Implementing the Peek Implementing the Clear Implementing the Printall Emank X Mezank !!

3 Implementing the enqueue operation
New nodes should be inserted at the front of the list, so that they become the top of the stack. 2 New item Front Rear Ahmed 1 Ali Mohamed Ghadeer Mohamed Ghadeer Ali Front Rear Ahmed Presented & Prepared by: Mahmoud R. Alfarra

4 Pseudo code of the enqueue operation
Create new object If rear points to null rear= NewItem Front = NewItem NewItem.next = null Else NewItem.next = rear size++ index++ Presented & Prepared by: Mahmoud R. Alfarra

5 Implementing the dequeue operation
The removed element should be removed from the front of the list. Front Rear 1 Ali Mohamed Ghadeer Mohamed Ghadeer Ali Front Rear Ahmed Presented & Prepared by: Mahmoud R. Alfarra

6 Pseudo code of the DeQueue operation
If front points to null print (the queue is empty) Else for (current = Rear, current.next != Front, current = current.next); Front = current; index--; size--; Presented & Prepared by: Mahmoud R. Alfarra

7 Implementing the Peek operation
The retrieved element should be element of the Front of the list. Front.name Front.ID Front.data… Presented & Prepared by: Mahmoud R. Alfarra

8 Pseudo code of the Peek operation
If Front points to null print (the queue is empty) Else return top Presented & Prepared by: Mahmoud R. Alfarra

9 Implementing the Clear operation
The clearing of Queue means removing all the elements by set the Front and Rear point to null. 2 1 Front Rear X X 2 1 Ali Mohamed Ghadeer Presented & Prepared by: Mahmoud R. Alfarra

10 Pseudo code of the clear operation
If Front points to null print (the stack is empty) Else Rear = null; Front = null; index = -1; size = 0; Presented & Prepared by: Mahmoud R. Alfarra

11 Implementing the Printall operation
The Print of all elements' data of the Queue means that we have to create a new pointer points every time to the next element. current Mohamed Ghadeer Ali Front Rear Ahmed 4 3 2 1 Depending on your understanding of the Dequeue operation, write the pseudo code and method of the PrintAll operation HW 11.1 Presented & Prepared by: Mahmoud R. Alfarra

12 Sorting and Finding elements
Depending on your understanding of the printAll() operation, write a find method which search about a specific data. HW 12.2 Depending on your understanding of the printAll() operation, write a sort method which sorts the elements of the queue based on the name field. HW 12.3 Presented & Prepared by: Mahmoud R. Alfarra

13 Emank X Mezank !! مجالس الصالحين ... ترفع الإيمان

14 Next Lecture Tree


Download ppt "Presented By: Mahmoud Rafeek Alfarra"

Similar presentations


Ads by Google