Technically that's a statement, not a question, but check this out
http://en.wikipedia.org/wiki/Circular_buffer
Basically, any operating system uses these for loading files into. The basic idea is that you have a fixed chunk of memory to work with.
#include <stdio.h>
#include<ctype.h>
# define MAXSIZE 200
int cq[MAXSIZE];
int front,rear;
void main()
{
void add(int,int [],int,int,int);
int del(int [],int ,int ,int );
int will=1,i,num;
front = 1;
rear = 1;
clrscr();
printf("
Program for Circular Queue demonstration through array
");
while(will ==1)
{
printf("
MAIN MENU:
1.Add element to Circular Queue
2.Delete element from the Circular Queue
");
scanf("%d",&will);
switch(will)
{
case 1:
printf("
Enter the data... ");
scanf("%d",&num);
add(num,cq,MAXSIZE,front,rear);
break;
case 2: i=del(cq,MAXSIZE,front,rear);
printf("
Value returned from delete function is %d ",i);
break;
default: printf("
Invalid Choice . ");
}
printf("
Do you want to do more operations on Circular Queue ( 1 for yes, any other key to exit) ");
scanf("%d" , &will);
} //end of outer while
} //end of main
void add(int item,int q[],int MAX,int front,int rear)
{
rear++;
rear= (rear%MAX);
if(front ==rear)
{
printf("
CIRCULAR QUEUE FULL
");
return;
}
else
{
cq[rear]=item;
printf("
Rear = %d Front = %d ",rear,front);
}
}
int del(int q[],int MAX,int front,int rear)
{
int a;
if(front == rear)
{
printf("
CIRCULAR STACK EMPTY
");
return (0);
}
else
{
front++;
front = front%MAX;
a=cq[front];
return(a);
printf("
Rear = %d Front = %d ",rear,front);
}
}
glass tumler
What is the difference between linear and circular queue? In: http://wiki.answers.com/Q/FAQ/2545-37 [Edit categories]The Queue by Default is Linear, it would be termed as Circular if the Last Element of the Queue pointsto the first element of the List
A queue is simply a FIFO i.e first in first out. In queue we've front and rear. Front is the initial or first location of the queue whereas rear indicates the last entry location in the queue. In the circular queue the location of front and rear will be the same IF the total space of the circular queue is utilized. Each element has its position no. for insertion , if we set the 5th element as the front element then after every insertion the ptr indicates the 5th element as front. in deletion, the fifth element is deleted every time it is the rear position. after deletion of an element the queue rotates and every time the rear indicates the 5th element of the circular queue. and every time the 5th location element is deleted.
An ordinary queue requires constant time access to the first and last elements, because all insertions occur at the back of the queue and all extractions at the front. Thus we require two pointers. However, with a circular queue, the next element after the last element is always the first element, thus we gain constant-time access to both the front and back of the queue through a single pointer to the back of the queue.
The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. Advantage of this type of queue is that empty location let due to deletion of elements using front pointer can again be filled using rear pointer.
glass tumler
Application of queue- 1. Task waiting for line printer 2.Time sharing by CPU 3.access to disk storage.. I am not able to find out any application of circular queue..It would be great if anybody help me out
What is the difference between linear and circular queue? In: http://wiki.answers.com/Q/FAQ/2545-37 [Edit categories]The Queue by Default is Linear, it would be termed as Circular if the Last Element of the Queue pointsto the first element of the List
A queue is simply a FIFO i.e first in first out. In queue we've front and rear. Front is the initial or first location of the queue whereas rear indicates the last entry location in the queue. In the circular queue the location of front and rear will be the same IF the total space of the circular queue is utilized. Each element has its position no. for insertion , if we set the 5th element as the front element then after every insertion the ptr indicates the 5th element as front. in deletion, the fifth element is deleted every time it is the rear position. after deletion of an element the queue rotates and every time the rear indicates the 5th element of the circular queue. and every time the 5th location element is deleted.
A queue is simply a FIFO i.e first in first out. In queue we've front and rear. Front is the initial or first location of the queue whereas rear indicates the last entry location in the queue. In the circular queue the location of front and rear will be the same IF the total space of the circular queue is utilized. Each element has its position no. for insertion , if we set the 5th element as the front element then after every insertion the ptr indicates the 5th element as front. in deletion, the fifth element is deleted every time it is the rear position. after deletion of an element the queue rotates and every time the rear indicates the 5th element of the circular queue. and every time the 5th location element is deleted.
An ordinary queue requires constant time access to the first and last elements, because all insertions occur at the back of the queue and all extractions at the front. Thus we require two pointers. However, with a circular queue, the next element after the last element is always the first element, thus we gain constant-time access to both the front and back of the queue through a single pointer to the back of the queue.
The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. Advantage of this type of queue is that empty location let due to deletion of elements using front pointer can again be filled using rear pointer.
Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.
Circular queue have less memory consuption as compared to linear queue because while doing insertion after deletion operation it allocate an extra space the first remaining vacant but in circular queue the first is used as it comes immediate after the last.
The round robin scheduling algorithm works by placing all processes in a circular queue and allotting each process a single time slice until all processes are completed. If process A required 2 time slices, process B required 1 time slice, and process C required 3 time slices the queue would be as follows: A > B > C > A > C > C.
cicular queue :D if you want to implement the round robin you need the data structure of circular queue so that when we give the time quantum for the processes then if that process is complete in that time period then its ok but if not then we have to put that process in the queue so that all other processes are also get the time to execute i.e. to remove starvation
The advantage of multilevel queue scheduling is that it covers all disadvantage of all others scheduling...................... The main disadvantage of multilevel queue scheduling is that it is very difficult to understand and it takes a lot of time........ By waqar ahmad awan (0333-9996376)