hello iam trying a circular queue in linked list and array there are two questions for me
1.how can circular queue can be implemented in a normal linked list??i think it can be implemented in circular singly linked list right??

2.if i implement it in array how i will connect last element with first element????

1.how can circular queue can be implemented in a normal linked list??i think it can be implemented in circular singly linked list right??

Right

2.if i implement it in array how i will connect last element with first element????

When you reach the last element of the array, return to the first element

r u saying like dis???@waltp

int n=5;
int front=-1,int rear=-1;
void enqueue()
{
if(rear==n-1)
{
front=0;
}
else
{
rear=rear+1;
queue[rear]=value;



}

i think linked will be easy to implement rather than arrays

Format your code!!! You know better!

It's a circular queue. front and rear would be independent of each other. You've tied them together messing up the contents of the queue. But the idea is correct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.