mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-28 00:24:21 +00:00
Add animation player (#1877)
* Add auto slide controller. * Fix the animation blocks. * renamed as animation_player * Bug fixes * Refine animation player controls
This commit is contained in:
@@ -368,13 +368,13 @@ To implement a queue, we need a data structure that allows adding elements at on
|
||||
|
||||
As shown in the figure below, we can treat the "head node" and "tail node" of a linked list as the "front" and "rear" of the queue, respectively, with the rule that nodes can only be added at the rear and removed from the front.
|
||||
|
||||
=== "LinkedListQueue"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "push()"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "pop()"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
Below is the code for implementing a queue using a linked list:
|
||||
@@ -396,13 +396,13 @@ Based on this design, **the valid interval containing elements in the array is `
|
||||
|
||||
As you can see, both enqueue and dequeue operations require only one operation, with a time complexity of $O(1)$.
|
||||
|
||||
=== "ArrayQueue"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "push()"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "pop()"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
You may notice a problem: as we continuously enqueue and dequeue, both `front` and `rear` move to the right. **When they reach the end of the array, they cannot continue moving**. To solve this problem, we can treat the array as a "circular array" with head and tail connected.
|
||||
|
||||
Reference in New Issue
Block a user