QueuePrepared by:      Eng. Ahmed & Mohamed Taha
Agenda Introduction to Queue. How Queue works. Operations performed on Queue. Queue Implementation.
Introduction to Queue Queue is an ordered collection of items in which new data  items are added at the end, or tail, of ...
Introduction to QueueCompany Logo
Introduction to QueueCompany Logo
Introduction to QueueCompany Logo
Queue Implementationusing Object Oriented    Programming
Queue Implementation                     using Array#include <iostream.h>#include <conio.h>#include <stdlib.h>#define max_...
Queue Implementation                         using address     /////////////////////////////funcions     // Initialize Fun...
Queue Implementation                            using address// Insert Functionvoid queue:: insert(int item){           if...
Queue Implementation                           using address// Remove Functionint queue:: remove(){         if (is_empty()...
Queue Implementation                                        using address// Print all elements Funcionvoid queue:: print_a...
Queue Implementation      using addressvoid main(){         clrscr();         queue q;         q.insert(1);         q.inse...
Upcoming SlideShare
Loading in …5
×

Queue oop

1,894 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,894
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
63
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Queue oop

  1. 1. QueuePrepared by: Eng. Ahmed & Mohamed Taha
  2. 2. Agenda Introduction to Queue. How Queue works. Operations performed on Queue. Queue Implementation.
  3. 3. Introduction to Queue Queue is an ordered collection of items in which new data items are added at the end, or tail, of the queue while other data are removed from the front, or head, of the queue. For this reason, a queue is referred to as a FIFO structure (First-In First-Out) The main primitive operations of a queue are known as:  Add adds a new node  Remove removes a node Additional primitives can be defined:  IsEmpty: reports whether the queue is empty  IsFull: reports whether the queue is full  Initialize: creates/initializes the queue  Destroy: deletes the contents of the queue (may be implemented by re-initializing the queue)
  4. 4. Introduction to QueueCompany Logo
  5. 5. Introduction to QueueCompany Logo
  6. 6. Introduction to QueueCompany Logo
  7. 7. Queue Implementationusing Object Oriented Programming
  8. 8. Queue Implementation using Array#include <iostream.h>#include <conio.h>#include <stdlib.h>#define max_size 100#define TRUE 1#define FALSE 0typedef int boolean;/************************************/Class queue{ private: int items[max_size]; int front,rear; public:};
  9. 9. Queue Implementation using address /////////////////////////////funcions // Initialize Function void queue:: queue() { front=0; rear=-1; }// Is_empty Functionboolean queue:: is_empty(){ if (rear < front) return TRUE; return FALSE;}
  10. 10. Queue Implementation using address// Insert Functionvoid queue:: insert(int item){ if (rear == max_size-1) { cout<<"Queue is Overflow"; exit(0); } else rear++; items[rear]=item;}
  11. 11. Queue Implementation using address// Remove Functionint queue:: remove(){ if (is_empty()) { cout<<"Queue is underflow"; return -1; } int item=items[front]; front++; return item;}
  12. 12. Queue Implementation using address// Print all elements Funcionvoid queue:: print_all_elements (){ cout<<"the current items of the queue are:"<<endl; for(int i=front;i<=rear;i++) cout<<items[i]<<" "; cout<<endl;}
  13. 13. Queue Implementation using addressvoid main(){ clrscr(); queue q; q.insert(1); q.insert(2); q.insert(3); q.insert(4); q.print_all_elements(q); int val=q.remove(); val=q.remove(); q.print_all_elements(); q.insert(5); q.insert(6); q.print_all_elements(); getch();}

×