Sei sulla pagina 1di 5

Script For Circular Queue

1.Define Circular Queue with example(2)


2.Operations on Circular Queue (2)
3. Circular Queue Insert Operation (6)
Explain the following
Description
Diagrams
C-Routine
4.Circular Queue Delete Operation (6)
Explain the following
Description
Diagrams
C-Routine
16 Marks
------------------------------------------------------------------------

1.C-Routine for Insert Operation Circular Queue

void CEnqueue (int X)

if (Front = = (rear + 1) % Maxsize)

print ("Queue is overflow");

else

if (front = = -1)

front = rear = 0;

else

rear = (rear + 1)% Maxsize;

CQueue [rear] = X;

}
}

2.C-Routine for Delete Operation Circular Queue

int CDequeue ( )

if (front = = -1)

print ("Queue is underflow");

else

X = CQueue [Front];

if (Front = = Rear)

Front = Rear = -1;

else

Front = (Front + 1)% maxsize;

return (X);

}
Linked Implementation of Queue (8)
Script
1.Define Queue with example(1)
2.Operations on Queue (1)
3.Implementation of Queue
i) Array Implementation of Queue
ii) Linked Implementation of Queue
4. Linked Implementation of Queue(6)

i) Queue Insert Operation (3)


Explain the following
Description
Diagrams
C-Routine
ii) Queue Delete Operation (3)
Explain the following
Description
Diagrams
C-Routine
8 Marks
-----------------------------------------------------------

Linked Implementation of Queue

3.C-Routine for Insert Operation Linked Implementation of Queue

Struct Node

int Element;

Struct Node *Next;

}* Front = NULL, *Rear = NULL;

void Enqueue (int X)

{
Struct node *newnode;

newnode = Malloc (sizeof (Struct node));

if (Rear = = NULL)

newnode ->data = X;

newnode ->Next = NULL;

Front = newnode;

Rear = newnode;

else

newnode ->data = X;

newnode ->Next = NULL;

Rear ->next = newnode;

Rear = newnode;

4.C-Routine for Insert Operation Linked Implementation of Queue

void Dequeue ( )

Struct node *temp;

if (Front = = NULL)
printf("Queue is underflow");

else

temp = Front;

if (Front = = Rear)

Front = NULL;

Rear = NULL;

else

Front = Front ->Next;

free (temp);

Potrebbero piacerti anche