translation: Update the figures for the chapter of stack and queue (#1084)

* Update the figures for the chapter of stack and queue

* Bug fixes and reducing file size
This commit is contained in:
Yudong Jin
2024-03-04 14:23:09 +08:00
committed by GitHub
parent 87e5b297f8
commit c16476d97b
50 changed files with 22 additions and 22 deletions

View File

@@ -321,13 +321,13 @@ To implement a queue, we need a data structure that allows adding elements at on
As shown in the figure below, we can consider the "head node" and "tail node" of a linked list as the "head" and "tail" of the queue, respectively. We restrict the operations so that nodes can only be added at the tail and removed at the head.
=== "LinkedListQueue"
![Implementing Queue with Linked List for Enqueue and Dequeue Operations](queue.assets/linkedlist_queue.png)
![Implementing Queue with Linked List for Enqueue and Dequeue Operations](queue.assets/linkedlist_queue_step1.png)
=== "push()"
![linkedlist_queue_push](queue.assets/linkedlist_queue_push.png)
![linkedlist_queue_push](queue.assets/linkedlist_queue_step2_push.png)
=== "pop()"
![linkedlist_queue_pop](queue.assets/linkedlist_queue_pop.png)
![linkedlist_queue_pop](queue.assets/linkedlist_queue_step3_pop.png)
Below is the code for implementing a queue using a linked list:
@@ -349,13 +349,13 @@ With this design, **the effective interval of elements in the array is `[front,
Both enqueue and dequeue operations only require a single operation, each with a time complexity of $O(1)$.
=== "ArrayQueue"
![Implementing Queue with Array for Enqueue and Dequeue Operations](queue.assets/array_queue.png)
![Implementing Queue with Array for Enqueue and Dequeue Operations](queue.assets/array_queue_step1.png)
=== "push()"
![array_queue_push](queue.assets/array_queue_push.png)
![array_queue_push](queue.assets/array_queue_step2_push.png)
=== "pop()"
![array_queue_pop](queue.assets/array_queue_pop.png)
![array_queue_pop](queue.assets/array_queue_step3_pop.png)
You might notice a problem: as enqueue and dequeue operations are continuously performed, both `front` and `rear` move to the right and **will eventually reach the end of the array and can't move further**. To resolve this issue, we can treat the array as a "circular array."