affiliate marketing
Showing posts with label IMPLEMENTATION OF LINEAR QUEUE USING ARRAYS coding. Show all posts
Showing posts with label IMPLEMENTATION OF LINEAR QUEUE USING ARRAYS coding. Show all posts

Monday, 12 December 2011

IMPLEMENTATION OF LINEAR QUEUE USING ARRAYS


IMPLEMENTATION OF LINEAR QUEUE USING ARRAYS


Aim
To write a C-program to implement linear queue data structure using arrays.

Algorithm
STEP 1: Start
STEP 2: [Include all header files]
STEP 3: [Declare the variables]
STEP 4: [If n->1 call the function Enqueue( )]
STEP 5: [If n->2 call the function Dequeue( )]
STEP 6: [If n->3 call the function Peep( )]
STEP 7: [If n->4 call the function Size( )]
STEP 8: [If n->5 call the function View( )]
STEP 9: [else Exit( )]
STEP 10: Stop

Algorithm for Enqueue( )
STEP 1: If[front= =rear]
               Initialize front=rear=0
STEP 2: else rear=(rear+1)% qsize
               Set queue[rear] =value
               [return]
Algorithm for Dequeue( )
STEP 1: If[front = =rear]
          1.1: temp=queue[front]
          1.2: Initialize front=rear=-1
STEP 2:else
          2.1: front=(front+1)% qsize
                 [return]

Algorithm for Peep( )
STEP 1:If [front= =rear]
STEP 1.1: temp=queue[front]
                  [return]

Algorithm for Size( )

STEP 1:If [front= =rear]
          1.1: Set f=front
           1.2: Set count=1
STEP 2: If [front!=rear]
          2.1: front=(front+1)%qsize
          2.2: set count=count+1
                 [return]

Algorithm for View( )

STEP 1: If [front = =rear]
               Write (“Queue is empty”)
STEP 2: else
               [display elements]        
             



Coding: