The greatest mistake you can make in life is to be continually fearing you will make one

Friday 12 February 2010

C Programs Based on Queue

Algorithm 1Write an algorithm for inserting an element in to the queue using array
    Let Q be the array of specified size, SIZE
  1. Initialize front=0,rear=-1
  2. Input the value to be inserted and assign to variable "data"
  3. If (rear > = SIZE)
          (a) Display "Queue Overflow"
          (b) Exit.
  4. Else
          (a) rear=rear+1;
  5. Q[rear]=data;
  6. Exit
Algorithm 2: Write an algorithm for deleting an element from the queue using array
    Let Q be the array of specified size,SIZE
  1. if (rear < front )
        (a) front=0,rear=-1
        (b) Display "The queue is empty"
        (c) Exit
  2. else
        (a) Data=Q[front]
        (b) front=front+1;
  3. Exit

No comments:

Post a Comment