41 questions
1
vote
1
answer
53
views
Is circular linked list needed for "Circular" queue?/
I am learning about queue data structure in python. I learnt the implementation of a queue using list in python and the issue of memory wastage when we dequeue a few elements from the front. We use a ...
0
votes
1
answer
80
views
How to achieve maximum throughput without using lock-free mechanism? On thread-safety circular queue
I use two mutexes for enqueueTS() and dequeueTS(), so that writer and reader threads can run simultaneously without waiting for each other. However, both enqueueTS() and dequeueTS() can affect member ...
1
vote
0
answers
106
views
Unexpected Increase in Latency with More Readers in Multi-threaded Circular Queue Implementation in C++
I have implemented a circular queue using an array in C++. The queue uses two atomic variables, front and rear, to manage enqueue and dequeue operations. When an element is enqueued, rear is ...
2
votes
1
answer
479
views
Queue Implementation Using a Circular Array
I have to implement a queue using a circular array and am having difficulty.
This is what should happen:
The enqueue() function returns a bool value: true if the queue is non-full prior to enqueuing ...
0
votes
1
answer
102
views
Why did Donald Knuth say that when implementing a circular queue with sequential allocation, overflow will not be detected when F = 0
In the 2.2.2 sequential allocation section, TAOCP volume 1 , Donald Knuth mentions that F = R = 0 is for the two cases (4) and (5) of the circular queue,
but if we use (6a) and (7a), we should set F =...
1
vote
1
answer
121
views
Inserting a number into a circular queue causes an infinite loop
I'm working on a C program that implements a queue, and I'm encountering an issue with an infinite loop.
The program is supposed to perform insertion, traversal, and deletion operations on the queue.
...
1
vote
1
answer
96
views
I am trying to implement this using a circular queue. My program executes but says terminated succesfully when build&ran
LinkSort.adb file
with Ada.Text_IO; use Ada.Text_IO;
procedure LinkSort is
type JobType is (Accountant, Analysist, Manager, Manufacturing, Programmer, Inventory, Sales, SoftwareEnginner);
...
0
votes
0
answers
72
views
Confusion about enqueue-ing datas into circular-queue recursively
In fact, this is not a main problem, I encountered this issue while doing practice about BST traversal with circular-queue.
I tried to define inorder traversal recursively and so enqueue-ing data also ...
-1
votes
1
answer
41
views
Why does my queue initializing function (c99) returns segmentation fault?
/* Queue structure which holds all necessary data */
typedef struct queue {
int head;
int tail;
void** vals;
int len;
int count;
} queue_t;
/* creates a new queue with a given ...
1
vote
0
answers
186
views
Undefined reference to copy
This is a function for doubling the circular queue capacity in C
(https://i.sstatic.net/xxhah.jpg)
Code source : Fundamentals of data structures in C
#include <stdio.h>
#include <stdlib.h>
...
0
votes
0
answers
322
views
Implementation of Circular Queue using array
So I have to implement a circular queue using array and I've used the following code to do so. However, for some reason when I try to add the 5th element to my queue, it does not seem to work. ALso, ...
0
votes
0
answers
99
views
Handling Unknown user input in C
Circular Queue in C
Currently working on a code that gives us an integer value (1,2,3) along side with a datatype either integer/char/string. Here,
1 -> Enqueue
2 -> Dequeue
3 -> Display
For ...
0
votes
1
answer
190
views
Front and rear pointers of circular queue exceed the size of array
front and rear pointers of circular queue are exceeding the size of array which can be seen in the print statement the input given for size was 3 where pointers go till the value 4 and 6.It would be ...
0
votes
1
answer
544
views
Circular Queue in Javascript
I was going through a book on Data Structures and Algorithm with JavaScript when I found this piece of codes.
I need someone to help me explain the logic behind the code here, also the logic behind ...
0
votes
0
answers
356
views
Popping an element from circular queue in C
So, i tried to delete a particular element in a circular queue, and used its index as front and back. When I ran the code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#...
0
votes
1
answer
82
views
In a circular queue how to check if the iterator is greater than and equal to the front element of the queue
struct PCB
{
int PID;
int burstTime;
int arrivalTime;
int priorityScore;
int startTime;
int finishTime;
};
struct Queue
{
int front;
int rear;
int length; // ...
0
votes
1
answer
177
views
why does my dynamically allocated array implementation of queue data structure NOT update on the second call?
I'm learning Data Structures as required of me by my university. I've implemented the Queue DS using Dynamic Array but it somehow doesn't work. It updates the value on the first enqueue method call ...
1
vote
1
answer
241
views
Why is my Circular Array Queue not adding the very last inputted value?
I'm having some difficulty with fully implementing my Circular Array Queue with Java. Specifically, my enqueue is failing to queue the very last value inputted in my queue. I've tested dequeuing and ...
0
votes
0
answers
94
views
Unable to display elements in circular queue
I am learning circular queue and I am facing some error.
While displaying the queue it only shows the first and last element, after deleting an element it gets even worse, now I don't know where ...
0
votes
1
answer
481
views
How can I display dequeued items in a Circular Queue?
I need to make a program that can keep track of dequeued elements. I was thinking of using three instances of the CircularQueue class, one for all customers as they arrive at the my shop, another two ...
0
votes
1
answer
292
views
Python initialize a list in a class
I am trying to solve a leetcode question using list: Design Circular Queue.
But it throws an error:
IndexError: list assignment index out of range
self.queue[self.tail] = value
My code:
class ...
1
vote
0
answers
95
views
POST data will not enqueue to PHP Circular Queue
I have a Circular Queue I've made using PHP with all of the generic functions you'd see like dequeue, enqueue, peek etc in a file queue.php
I am trying to submit form data using AJAX that has been pre-...
0
votes
1
answer
47
views
AJAX does not return anticipated response [duplicate]
I'm trying to start to use AJAX to
send a Javascript variable from one PHP file to another
that will enqueue it to a queue function I have created
and then peek that ID in the queue by changing the &...
0
votes
1
answer
86
views
Explanation for the following expected circular queue result
I'm trying to create a circular queue and come across this problem.
As you see, my answer is incorrect. I still don't understand the reason why it is the case, so let's go through everything again.
...
0
votes
1
answer
47
views
Any idea why this function is defined like this in a circular queue?
I am currently studying circular cues. I came across these functions while studying using the textbook.
int NextPosIdx(int pos)
{
if (pos == QUE_LEN -1)
return 0;
else
return ...
0
votes
3
answers
9k
views
Insert and Delete element on Circular Queue
I'm studying about circular queue in data structure . As you can see from the code below, I try to delete a specific data and insert data on Circular queue. However, when I try to run it there's a ...
0
votes
2
answers
98
views
Why is the variable value changing automatically?
This is my code
int front=-1, rear=-1, CQUEUE[MAX];
int isFull()
{
if((rear=MAX-1 && front==0) || front==rear+1)
return 1;
else
return 0;
}
void ...
1
vote
2
answers
458
views
simple patient managing program using queue
I'm making simple patient managing program using circular queue but q.rear always have "0" value while executing exit_hos()
I thought that addq() makes variable "rear" different, ...
0
votes
1
answer
1k
views
An efficient way to implement circular priority queue?
I have designed a circular priority queue. But it took me a while because it is so conditional and has a bit much of a time complexity.
I implemented it using a list. But I need a more efficient ...
0
votes
1
answer
248
views
implementing a copy constructor, destructor, and how to overload assignment operator for queues
This is what i have, but i am not sure that this works. I am not sure if copying this way is efficient,and i couldn't figure a way to overload. when copying, i am giving both the same size, setting ...
0
votes
1
answer
451
views
EnQueue method not returning correctly in C++ circular queue?
I have less than 3 months experience coding, so I've started using LeetCode to just build hours working with code beyond what's assigned in school.
I was working on trying to build a circular queue (...
0
votes
0
answers
98
views
How to display the elements of a Circular Queue in an efiicient (circular) manner?
Most of the programs that I saw produced the results in a linear manner , like displaying a normal one-dimensional array.
But here I have a circular queue, and the elements in it must be displayed ...
0
votes
1
answer
140
views
Circular Queue toString method ignoring some conditions
when I call my toString() method it doesn't work if after the index wraps around (front > rear). I have included the code below. After, I enqueue(5) and enqueue(6), the toString seems to be completely ...
-1
votes
1
answer
245
views
Dequeue final node in circular linked list
When I am trying to dequeue the final node in a circular linked list based queue in C++ I am getting a segmentation fault. The rest of the elements before the final one are removed successfully, its ...
0
votes
2
answers
1k
views
can someone please tell is there any java built in package for Circular Queue?
I want to know that is there any java built-in package for a circular queue
and if it exists then what is the constructor to use it?
0
votes
2
answers
520
views
Getting an item from one position in a Circular Queue using an iterator
I have a Circular queue, but I don't know how to get a certain item from some position, the header would be: public E peeki(int index) and using a generic Iterator.
0
votes
1
answer
2k
views
Circular queue size using mod
Let's say I implement a circular queue using an array. How could I calculate the size of the queue? By size I mean the number of elements between the front and the rear. I want to use the modulo ...
1
vote
2
answers
1k
views
Circular Queue in Java
I am implemeting a circular queue in java which will accept objects (Employee) as entries. Now I have a method to edit the surname of the specific object, but somehow I cannot access the surname ...
2
votes
1
answer
1k
views
Understanding queue arithmetic in data structures
When an element is inserted in a queue, REAR = REAR + 1. When an element is deleted from the queue, FRONT = FRONT + 1 when queues are implemented using arrays.
Now, initially, both FRONT = REAR = -1 ...
3
votes
2
answers
334
views
Circular Queue theory
I'm need help understanding the Circular Queue concept. I read a couple post on stackoverflow and none of the answers are answering a mental block I'm having.
For example say I have 8 cells in a ...
0
votes
2
answers
8k
views
Circular Queue using Linked List
I want to create a circular queue using linked list,also i want to create instance of that data structure(queue) not just one queue, many queues without repeating the code. this is what i came up with....