answersLogoWhite

0


Best Answer

Circular queue is a linear data structure that follows the First In First Out principle. A re-buffering problem often occurs for each dequeue operation in a standard queue data structure. This is solved by using a circular queue which joins the front and rear ends of a queue.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the need of circular queue in data structures?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between linear and circular queue?

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


The need for complex data structures?

Explain the need for complex data structures


What kind of data structure is required to implement the round-robin scheduling?

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


What is the advantage of circular queue over simple queue?

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.


What are the applications for circular linked lists?

A singly-linked circular list is useful for implementing queue data structures with minimum overhead. Normally we implement a queue with two pointers: one to the tail for insertions and one to the head for extractions. With a circular list we only need to maintain a single pointer to the tail because the tail always points "forwards" to the head (instead of null as it normally would), thus achieving constant-time access to both the head and tail via a single pointer. Circular linked lists are generally useful wherever "wraparound" is necessary. That is, from any given node in the list, we can traverse forwards with the guarantee that we will eventually arrive back at that same node. With doubly-linked circular lists we have the advantage of traversing in either direction (bi-directional traversal).


Data Structures and Algorithms in Java?

Data structures has been implemented in Java language already, you just need to import it and start using it. Data Structures are located in Java.util packages.ArrayArraylistVectorHashMapHashTableLinkedListStackQueueCollection this are the few I know.Thanks,Anandkumar.R


C plus plus program to implement circular queue using doubly linked list?

#include<iostream.h> class node { public: int data; node* link; }; class queue { node* front; node* back; public: queue() { front=NULL; back=NULL; } void enqueue(int d) { node* ptr; ptr=new node; ptr->data=d; ptr->link=NULL; if(front==NULL) { front=ptr; back=ptr; } else { back->link=ptr; back=back->link; } } void dequeue() { node* ptr; ptr=front; if(front==NULL) cout<<"\n Nothing can be deleted. \n"; else { ptr=front; front=front->link; delete ptr; ptr=NULL; cout<<"\n The first element has been deleted.\n"; Front(); } } void If_Empty() { if(front==NULL) cout<<"\n The queue is empty.\n "; } void Front() { if(front!=NULL) cout<<"\n The first element is "<<front->data<<endl; } }; void main() { queue q; int data; char opt; do { cout<<" Enter your data:\t"; cin>>data; q.enqueue(data); cout<<"\n Do you want to continue:\t"; cin>>opt; }while(opt=='y'opt=='Y'); q.Front(); q.dequeue(); q.If_Empty(); q.dequeue(); q.dequeue(); q.If_Empty(); q.dequeue(); }


Explain how circular queue differs from linear queue?

Both linear and circular queues are constructed from nodes: struct node { T data; // the node's value (of type T) node* next; // refers to the next node in the sequence }; To implement a queue efficiently, we need to keep track of both the front and back of the queue. This is because all insertions occur at the back of the queue while all extractions occur at the front of the queue, and both operations must be performed in constant time. struct queue { node* head; // refers to the front of the queue node* tail; // refers to the back of the queue }; Initially, the queue is empty, so both the head and tail must be set to NULL. We use the following function to insert some data at the back of the queue: node* push (queue* q, T value) { node* n = malloc (sizeof (node)); n->data = value; n->next = NULL; if (q->tail == NULL) { q->head = n; q->tail = n; } else { q->tail->next = n; q->tail = n; } return n; } The following function extracts the head node: void pop (queue* q) { node* n = q->head; if (q->head) { q->head = q->head->next; // may be NULL if (!q->head) q->tail = NULL; } free n; } In a circular queue, we don't need to keep track of the head because tail->next always points to the head unless tail is NULL. So we can eliminate the head pointer from the queue structure: struct queue { node* tail; }; The insertion function therefore changes as follows: node* push (queue* q, T value) { node* n = malloc (sizeof (node)); n->data = value; if (q->tail == NULL) { n->next = n; q->tail = n; } else { n->next = q->tail->next; q->tail->next = n; q->tail = n; } return n; } And the extraction function changes as follows: void pop (queue* q) { if (q->tail == NULL) return; // empty list node* n = q->tail; if (q->tail == q->tail->next) // a list of one q->tail = NULL; else q->tail->next = q->tail->next->next; // adjust the head free n; }


Why need supplementary variable technique?

To convert the non-Markovain queue into Markovian queue.


What is the unix command for list all jobs in the waiting queue?

You need to indicate what queue you are talking about, since several queues could be considered the "wait queue".


What are the applications of circular queue?

Priority queues can be found in operating systems for load-balancing and interrupt handling, network servers for bandwidth management, compression algorithms (such as Huffman encoding), Dijkstra's algorithm, Prim's algorithm and artificial intelligence systems.


Which data structure is Best for library management system wheater Tree or Linked list?

It depends on what you intend to do with the data. The assumption is the data is dynamic, the number of elements are not known in advance. Binary trees are best if you want to sort the data as it is entered. Linked lists are best if you simply want a list of sequential data, or need to implement a stack or a queue.