0% found this document useful (0 votes)
1K views5 pages

1.C-Routine For Insert Operation Circular Queue

The document contains routines for implementing circular queue and linked queue data structures in C. For circular queue, it includes routines for insertion and deletion of elements with descriptions and diagrams. For linked queue, it provides routines for insertion and deletion of nodes with descriptions and diagrams. The routines demonstrate using pointers to dynamically allocate memory and link nodes to implement the queue operations.

Uploaded by

wajbhara
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views5 pages

1.C-Routine For Insert Operation Circular Queue

The document contains routines for implementing circular queue and linked queue data structures in C. For circular queue, it includes routines for insertion and deletion of elements with descriptions and diagrams. For linked queue, it provides routines for insertion and deletion of nodes with descriptions and diagrams. The routines demonstrate using pointers to dynamically allocate memory and link nodes to implement the queue operations.

Uploaded by

wajbhara
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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);

You might also like