Questions tagged [deque]

For code for double ended queues, or code that wouldn't nearly be the same without a deque. Not for code that merely happens to use a deque incidentally but whose real focus is something else.

Filter by
Sorted by
Tagged with
3 votes
1 answer
194 views

Deque class for .Net (C#)

As .Net has no Deque class (Double-Ended Queue) in the Frameworks and I couldn't find an example implementation that I was happy with, I have written the following with the intent that I may post it ...
user avatar
1 vote
1 answer
152 views

Optimize Leetcode 239. Sliding Window Maximum using Swift

LeetCode problem 239. Sliding Window Maximum You are given an array of integers nums, there is a sliding window of size k which ...
user avatar
0 votes
2 answers
86 views

Python list subclass with O(1) prepend / How to get bisect to work with reverse sorted list

For a particular problem, I need to have a list that: supports O(1) prepend, and that I can call bisect.bisect_left on, which ...
user avatar
  • 243
1 vote
0 answers
102 views

How to create a maze solve search with BFS provide navigation movements

How should I structure this code to create a maze, solve it with breath-first-search (BFS) and to provide basic navigation movements by 1 step within maze with number of moves required to navigate? ...
user avatar
  • 11
2 votes
1 answer
128 views

Faster, indexed, heuristic doubly-linked list data structure in Java: implementation

I have this doubly-linked list data structure that runs all the single-element operations in \$\Theta(\sqrt{n})\$ time (refer to this post and this repository). (See this for benchmarks.) (See this ...
user avatar
  • 25.3k
1 vote
0 answers
42 views

Integer Double Ended Queue GO

I'm currently learning Go and I have decided to implement a Circular Doubly Linked List (Deque) structure for the training. Go is not my first language. I program mainly in Python, therefore I would ...
user avatar
4 votes
1 answer
78 views

Another Sliding Window - find each `k-size` window the maximum num. from an integer array/list

I've searched this site and find many similar questions, but not exactly the same as the one I'll post. This attempts to solve Leetcode 239: You are given an array of integers ...
user avatar
3 votes
1 answer
223 views

Deque class in Common Lisp

I created a library with two CLOS class to implement a deque structure similar to the one available in C++, plus a few Lisp-ian twists. The two classes are node, ...
user avatar
8 votes
2 answers
3k views

A simple thread-safe Deque in C++

I am trying to implement a thread-safe deque in C++. ThreadSafeDeque will be used by a FileLogger class. When threads call the <...
user avatar
  • 255
1 vote
1 answer
2k views

Deque implementation with array in Java

I'm trying to implement a deque data structure with an iterator in Java using array. Please help to review and point out things that I can improve on. ...
user avatar
1 vote
3 answers
3k views

Deque implemented using a circular array

I found a tutorial on implementing a deque using a circular array. I changed the implementation but I am not sure if it is correct or not. So I have one question: I wrote code that uses an ...
user avatar
4 votes
3 answers
675 views

A deque for up to one million elements

I have a task where I need to write my own deque and to this code was executed for 1 second, I get a result of 1.09 sec. The max count of elements is 1000000. How can I optimize it for better ...
user avatar
5 votes
2 answers
1k views

Linked deque implementation in C

I wrote a deque implementation in C for storing char *. It uses a doubly linked list, but I'm calling it a deque since it can only push/pop from the head and tail ...
user avatar
  • 151
1 vote
1 answer
3k views

Deque using doubly linked list

I was trying to implement a deque using a singly LL when I realized that eject() (popping the tail element) wasn't going to work without a pointer to the previous ...
user avatar
4 votes
2 answers
6k views

Implementation of std::deque

In the prior obsolete implementation of std::deque, I used two std::vectors to contain the elements. But the standard guarantees that pointers and references to elements aren't invalidated when an ...
user avatar