@@ -18,7 +18,7 @@ A [stack](../stack/README.md) is a queue with operations conducted in an opposit
18
18
19
19
As a queue only interacts with either the first or last element regardless during its operations,
20
20
it only needs to keep the pointers of the two element at hand, which is constantly updated as more
21
- elements are removed / added. This allows stack operations to only incur a * O(1)* time complexity.
21
+ elements are removed / added. This allows queue operations to only incur a * O(1)* time complexity.
22
22
23
23
## Notes
24
24
@@ -38,31 +38,3 @@ In the context of ordered operations, the lookup is only restricted to the first
38
38
Hence, there is not much advantage in using a array, which only has a better lookup speed (* O(1)* time complexity)
39
39
to implement a queue. Especially when using a linked list to construct your queue
40
40
would allow you to grow or shrink the queue as you wish.
41
-
42
- ### Queue Variants
43
-
44
- These are some variants of queue that are commonly used.
45
-
46
- #### Double Ended Queue (Deque)
47
-
48
- ![ Deque] ( https://media.geeksforgeeks.org/wp-content/uploads/anod.png )
49
-
50
- * Source: GeeksForGeeks*
51
-
52
- Deque is a variant of queue where elements can be removed or added from the head and tail of the queue.
53
- Deque could come in handy when trying to solve sliding window problems.
54
-
55
- A deque can be implemented in multiple ways, using doubly linked lists, arrays or two stacks.
56
-
57
- #### Monotonic Queue
58
-
59
- This is a variant of queue where elements within the queue are either strictly increasing or decreasing.
60
- Monotonic queues are often implemented with a deque.
61
-
62
- Within a increasing monotonic queue, any element that is smaller than the current minimum is removed.
63
- Within a decreasing monotonic queue, any element that is larger than the current maximum is removed.
64
-
65
- It is worth mentioning that the most elements added to the monotonic queue would always be in a
66
- increasing / decreasing order,
67
- hence, we only need to compare down the monotonic queue from the back when adding new elements.
68
-
0 commit comments