A queue is an ordered, first-in-first-out (FIFO) data structure. Typical implementations of queues support pushing elements to the back and popping them off the front position.
2
votes
2answers
55 views
Finding the Least Common Ancestor of a Binary Tree
Input a binary tree (the root node) and 2 other nodes that need to be assessed for finding the least common ancestor (LCA)
Code:
a. Finding the nodes first with either ...
3
votes
1answer
61 views
Queue Using Stack java implementation
Implemented this solution for the problem. Feedback and review if this can be improved in an way. Appreciate your help.
...
0
votes
2answers
42 views
C++ fixed-size queue full/empty signaling
I'm considering an application where a large data needs to be written to file often. I would like to use a queue and have a producer and consumer running on different threads. Additionally, I would ...
3
votes
2answers
55 views
Queue resizing array implementation
After learning about linked list implementations of a queue I was asked to try a resizing array implementation. I'm looking for constructive criticism.
...
3
votes
1answer
42 views
Queue implementation using two stacks
Here's my code and I want to know if there's a better method for doing so. While the question has stated two stacks I wonder if we could do only with one as well?
...
0
votes
0answers
22 views
3
votes
3answers
36 views
Array-based queue implementation using C
I wrote this header for generic use of a queue. The one thing I'm wondering is if I understood the usage of void*. I hope that if somebody teach me some conventions ...
1
vote
1answer
53 views
Pipeline with std::thread vectors and queue
here is my code, it works but after few iterations it slows down and stop without any error, I'm looking for a more efficient solution.
...
4
votes
1answer
92 views
Implementing Binary Tree using Queue in C#
I am in the process of learning data structures and I am trying to implement Binary Tree using Queue in C#.
Below are my Tree implementation classes.
...
1
vote
1answer
66 views
My Queue implementation is correct?
I have read CLRS Introduction to Algorithms book, now I'm on Elementary data structure chapter. I read about queue concept and try to implement in c.
I have tested a lot it work fine, but I have a ...
3
votes
2answers
75 views
Stack and Queue implemented with a LinkedList
I am looking for feedback on my implementations of Queue, Stack, and LinkedList using Java ...
3
votes
1answer
97 views
MazeRunner in Java - follow-up
I've refined a lot of the code from my previous question, and have also decided to include the logic that interprets a given text file. Any advice on how to improve the actual algorithm that solves ...
3
votes
1answer
82 views
MazeRunner in Java
To test the queue I perfected from one of my CR questions, I've developed a maze program that receives an input maze, starting and end positions, and solves it. I have separate software that handles ...
0
votes
0answers
54 views
Web scraper using Beautiful Soup
I am using Python 3 with Beautiful Soup to scrape web sites. I also used Thread to download images, but it will spend more than 30 minutes to get all information ...
2
votes
0answers
66 views
Blocking Memory Queue
This is a FIFO blocking memory queue in F# to be used as a component in a logging library.
...
0
votes
1answer
39 views
Multi-layer queue
I must write code for my classes which simulates multi-layers production line. But I don't even know how to check if it's good. Can anyone take a look at my code, please? First machine works in random ...
4
votes
2answers
86 views
DoublingQueue in Java
Inspired by this CR question, I decided to create my own queue! If you guys see anything taboo or have any improvements, please let me know. Ultimately I want it to be feature rich and bug free, with ...
11
votes
5answers
549 views
FiniteArrayQueue type with interface and unit tests
Doing some exercises on basic data structures, I learned about queues, and decided to roll my own to better understand how a basic queue can function. As the name indicates, this Queue is made from a ...
1
vote
1answer
43 views
Implement MyQueue using two stacks
I am taking a helper stack, which is used during dequeue. Kindly suggest improvement or some solution with less complexity.
...
2
votes
2answers
100 views
Array-based deque in Java
Are the conditions which I have included for insertion and deletion from front and rear sufficient and necessary? Have I missed some condition check? Or have I included some redundant condition?
<...
4
votes
3answers
99 views
Lock-free SPMC queue
Here is my lock-free queue implementation for single producer with some preallocated memory. T is a simple type with no need for move operations. I don't use ...
3
votes
0answers
79 views
Immutable queue implementation in Scala
I created a queue in which we can perform Enqueue, Dequeue and Traversing in Scala.
...
5
votes
1answer
34 views
Converting Binary Tree to LinkedLists
The problem statement is :
Given a binary tree, design an algorithm which creates a linked list of all the
nodes at each depth (e.g., if you have a tree with depth D, you'll have D linked
...
10
votes
3answers
942 views
Animal shelter simulation using Queues
This is of one the interesting problems I've solved:
An animal shelter holds only dogs and cats, and operates on a strictly "first in, first out" basis. People must adopt either the "oldest" (...
1
vote
0answers
202 views
Are there pitfalls to this solution to read messages from a queue in parallel?
I've posted a question on stackoverflow: How can I consequently read messages from a queue in parallel? I would like my own answer to be reviewed.
Situation
We have one message queue. We would like ...
3
votes
0answers
54 views
Updatable priority queue
This is an updatable priority queue. In contains an index (implemented as std::unordered_map) which maps a value to its position in the queue itself. The queue is ...
6
votes
1answer
67 views
Queue implementation in Java
This is my Queue implementation in Java. Would appreciate a review of the code.
...
6
votes
1answer
164 views
Priorizatable command queue
This code consistently executes commands with a given priority. How can I to improve it?
...
4
votes
3answers
112 views
Implementing CircularQueue using Linked List in C++
I'm currently doing a project, requiring me to implement a CircularQueue data structure in C++:
...
4
votes
2answers
837 views
Simple FIFO and LIFO ferry simulator
I am trying to make a ferry simulator with one ferry that works like a stack and another like a queue. I have a working class for stacks and queues with pop/push; I am trying to figure out how to ...
3
votes
2answers
83 views
LinkedList Queue implementation
I'm working on a project which simulates (very simple/watered down) a network. The basis of this is to learn how to implement a Queue. I understand there are many ...
2
votes
1answer
225 views
MPMC lock-free queue
I'm pretty new to the world of lock-free programming and would love some feedback on this code. I have been testing the queue with multiple producers and consumers, and with no unexpected output (yet)....
-1
votes
2answers
138 views
Stack using two queues
I have implemented the Stack using two Queues q1 and q2 respectively as shown below in the code. I would like to get you reviews on whether it's an efficient way of implementing it or now.
For Pop ...
5
votes
2answers
243 views
4
votes
3answers
139 views
Lock-free MultiConsumer/MultiProducer queue
I've written a simple lock-free multi-consumer/-producer FIFO queue.
It's supposed to work like this:
At any time many consumers may read from it
At any time multiple producers can write to it, ...
3
votes
2answers
75 views
Lockless SCSP queue
I'm looking for a code review on a class that I've written. It was my first attempt at lockless programming and I'd love any feedback I can get.
...
4
votes
2answers
314 views
Thread-safe lock free FIFO queue
A few years ago there was a need to add a FIFO queue between 2 threads into my project. At that time I've got some interesting idea how to do that without any atomics and locks. (There was a ...
-2
votes
2answers
120 views
8
votes
5answers
431 views
RingQueue implementation using std::array
I've recently finished implementing a ring queue based on std::array in C++11. I tried to write the code as if I were going to submit it to the C++ Standard ...
-3
votes
1answer
87 views
Verify FIFO dequeue algorithm
I have a FIFO queue of packets, which maintains:
Push index
Pop index
Count
I would like to assert my dequeuing algorithm:
...
5
votes
4answers
712 views
Implementation of C linked list (Queue) of C strings on mega AVR
I have been working on a mechanism to queue up strings coming into a system via a USART and have implemented it as a singly linked list. I have done my best to profile the code and its memory usage at ...
4
votes
1answer
66 views
Serializable Queue header only library
I was hoping someone could check the library I 'm working on to see if they could give any suggestions. My biggest issue right now is getting tuple to work with more than just the basic types and I ...
2
votes
1answer
232 views
Priority blocking queue implementation
This is a follow on question from one I asked a few days ago here: Single process blocking queue
Using the comments I determined that there probably isn't a pre-built solution for this and so I have ...
7
votes
1answer
968 views
Calculate the running median
I'm trying to solve a challenge where you need to calculate the median every time you add a number.
say you have a list of numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
...
3
votes
1answer
335 views
Making a copy constructor more flexible for ADT queue
I have constructed a copy constructor for an ADT queue. The copy constructor works fine. I would want to improve my code, but I don't really know how to shorten it to make it more flexible.
...
6
votes
1answer
158 views
Lock-free, multiple consumer, multiple producer queue
I'm implementing a lock-free, multiple consumer, multiple producer FIFO queue/pipe as an exercise in thinking about atomicity in operations.
My main concern is correctness of operation, my second ...
5
votes
1answer
919 views
Lockless multi user, multi consumer FIFO queue using C++11
One of the features that is missing from C++11 are lockless queues. Therefore I have decided to write one myself.
A few remarks:
I know the code isn't technically lockless. However the lock is only ...
5
votes
1answer
83 views
MailQueue - follow up
Follow up of this question.
Things altered:
Put logging (debug level) for creating and starting thread.
A separate thread for starting the different threads.
Locking object and synchronise for ...
7
votes
2answers
173 views
MailQueue implementation with auto start - stop
Previous question was a little portion of the mailQueue.
I finished the MailQueue, which has the ability to start and stop ...
6
votes
2answers
189 views
Templated queue implementation
I wrote an implementation for a simple queue in C++ (for practice, since there's an stl queue). I've been trying to focus on memory management and the rule of three. Any suggestions/improvements?
(...