diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque.png deleted file mode 100644 index 5f0bcd35..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/array_deque.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_pop_first.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_pop_first.png deleted file mode 100644 index 9d203a63..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_pop_first.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_pop_last.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_pop_last.png deleted file mode 100644 index 2c18b17a..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_pop_last.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_push_first.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_push_first.png deleted file mode 100644 index 8b7b352e..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_push_first.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_push_last.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_push_last.png deleted file mode 100644 index 6b3baf39..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_push_last.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step1.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step1.png new file mode 100644 index 00000000..e6f3c834 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step1.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step2_push_last.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step2_push_last.png new file mode 100644 index 00000000..6d5f96b9 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step2_push_last.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step3_push_first.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step3_push_first.png new file mode 100644 index 00000000..edd2c86e Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step3_push_first.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step4_pop_last.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step4_pop_last.png new file mode 100644 index 00000000..c27fda4e Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step4_pop_last.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step5_pop_first.png b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step5_pop_first.png new file mode 100644 index 00000000..10c9f605 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/array_deque_step5_pop_first.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/deque_operations.png b/docs-en/chapter_stack_and_queue/deque.assets/deque_operations.png index a3978832..d2413b67 100644 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/deque_operations.png and b/docs-en/chapter_stack_and_queue/deque.assets/deque_operations.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque.png deleted file mode 100644 index d6150201..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_pop_first.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_pop_first.png deleted file mode 100644 index b50944ef..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_pop_first.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_pop_last.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_pop_last.png deleted file mode 100644 index 8df34337..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_pop_last.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_push_first.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_push_first.png deleted file mode 100644 index 2cdd94a5..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_push_first.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_push_last.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_push_last.png deleted file mode 100644 index eed3f18e..00000000 Binary files a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_push_last.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step1.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step1.png new file mode 100644 index 00000000..fa24a79b Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step1.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step2_push_last.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step2_push_last.png new file mode 100644 index 00000000..ec4752ea Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step2_push_last.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step3_push_first.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step3_push_first.png new file mode 100644 index 00000000..e84278f5 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step3_push_first.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step4_pop_last.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step4_pop_last.png new file mode 100644 index 00000000..3d451a87 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step4_pop_last.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step5_pop_first.png b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step5_pop_first.png new file mode 100644 index 00000000..09ce1f53 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/deque.assets/linkedlist_deque_step5_pop_first.png differ diff --git a/docs-en/chapter_stack_and_queue/deque.md b/docs-en/chapter_stack_and_queue/deque.md index 367a0d58..83e7bb44 100644 --- a/docs-en/chapter_stack_and_queue/deque.md +++ b/docs-en/chapter_stack_and_queue/deque.md @@ -347,19 +347,19 @@ For a double-ended queue, both the head and the tail can perform enqueue and deq As shown in the figure below, we treat the head and tail nodes of the doubly linked list as the front and rear of the double-ended queue, respectively, and implement the functionality to add and remove nodes at both ends. === "LinkedListDeque" - ![Implementing Double-Ended Queue with Doubly Linked List for Enqueue and Dequeue Operations](deque.assets/linkedlist_deque.png) + ![Implementing Double-Ended Queue with Doubly Linked List for Enqueue and Dequeue Operations](deque.assets/linkedlist_deque_step1.png) === "pushLast()" - ![linkedlist_deque_push_last](deque.assets/linkedlist_deque_push_last.png) + ![linkedlist_deque_push_last](deque.assets/linkedlist_deque_step2_push_last.png) === "pushFirst()" - ![linkedlist_deque_push_first](deque.assets/linkedlist_deque_push_first.png) + ![linkedlist_deque_push_first](deque.assets/linkedlist_deque_step3_push_first.png) === "popLast()" - ![linkedlist_deque_pop_last](deque.assets/linkedlist_deque_pop_last.png) + ![linkedlist_deque_pop_last](deque.assets/linkedlist_deque_step4_pop_last.png) === "popFirst()" - ![linkedlist_deque_pop_first](deque.assets/linkedlist_deque_pop_first.png) + ![linkedlist_deque_pop_first](deque.assets/linkedlist_deque_step5_pop_first.png) The implementation code is as follows: @@ -372,19 +372,19 @@ The implementation code is as follows: As shown in the figure below, similar to implementing a queue with an array, we can also use a circular array to implement a double-ended queue. === "ArrayDeque" - ![Implementing Double-Ended Queue with Array for Enqueue and Dequeue Operations](deque.assets/array_deque.png) + ![Implementing Double-Ended Queue with Array for Enqueue and Dequeue Operations](deque.assets/array_deque_step1.png) === "pushLast()" - ![array_deque_push_last](deque.assets/array_deque_push_last.png) + ![array_deque_push_last](deque.assets/array_deque_step2_push_last.png) === "pushFirst()" - ![array_deque_push_first](deque.assets/array_deque_push_first.png) + ![array_deque_push_first](deque.assets/array_deque_step3_push_first.png) === "popLast()" - ![array_deque_pop_last](deque.assets/array_deque_pop_last.png) + ![array_deque_pop_last](deque.assets/array_deque_step4_pop_last.png) === "popFirst()" - ![array_deque_pop_first](deque.assets/array_deque_pop_first.png) + ![array_deque_pop_first](deque.assets/array_deque_step5_pop_first.png) The implementation only needs to add methods for "front enqueue" and "rear dequeue": diff --git a/docs-en/chapter_stack_and_queue/queue.assets/array_queue.png b/docs-en/chapter_stack_and_queue/queue.assets/array_queue.png deleted file mode 100644 index 29c7f496..00000000 Binary files a/docs-en/chapter_stack_and_queue/queue.assets/array_queue.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/array_queue_pop.png b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_pop.png deleted file mode 100644 index c57e6a19..00000000 Binary files a/docs-en/chapter_stack_and_queue/queue.assets/array_queue_pop.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/array_queue_push.png b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_push.png deleted file mode 100644 index 71dcd1d7..00000000 Binary files a/docs-en/chapter_stack_and_queue/queue.assets/array_queue_push.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step1.png b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step1.png new file mode 100644 index 00000000..7c0f8157 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step1.png differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step2_push.png b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step2_push.png new file mode 100644 index 00000000..8c9dd123 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step2_push.png differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step3_pop.png b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step3_pop.png new file mode 100644 index 00000000..029e6a35 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/queue.assets/array_queue_step3_pop.png differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue.png b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue.png deleted file mode 100644 index 7cff9b1b..00000000 Binary files a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_pop.png b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_pop.png deleted file mode 100644 index 6a43121f..00000000 Binary files a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_pop.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_push.png b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_push.png deleted file mode 100644 index a53b9f44..00000000 Binary files a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_push.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step1.png b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step1.png new file mode 100644 index 00000000..8b888a3a Binary files /dev/null and b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step1.png differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step2_push.png b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step2_push.png new file mode 100644 index 00000000..2b4c2731 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step2_push.png differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step3_pop.png b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step3_pop.png new file mode 100644 index 00000000..4fa752c4 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/queue.assets/linkedlist_queue_step3_pop.png differ diff --git a/docs-en/chapter_stack_and_queue/queue.assets/queue_operations.png b/docs-en/chapter_stack_and_queue/queue.assets/queue_operations.png index ce3a6f2b..13d9afa2 100644 Binary files a/docs-en/chapter_stack_and_queue/queue.assets/queue_operations.png and b/docs-en/chapter_stack_and_queue/queue.assets/queue_operations.png differ diff --git a/docs-en/chapter_stack_and_queue/queue.md b/docs-en/chapter_stack_and_queue/queue.md index c0dcb90a..1f3e07b7 100755 --- a/docs-en/chapter_stack_and_queue/queue.md +++ b/docs-en/chapter_stack_and_queue/queue.md @@ -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." diff --git a/docs-en/chapter_stack_and_queue/stack.assets/array_stack.png b/docs-en/chapter_stack_and_queue/stack.assets/array_stack.png deleted file mode 100644 index e8e3445b..00000000 Binary files a/docs-en/chapter_stack_and_queue/stack.assets/array_stack.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/array_stack_pop.png b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_pop.png deleted file mode 100644 index be56b586..00000000 Binary files a/docs-en/chapter_stack_and_queue/stack.assets/array_stack_pop.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/array_stack_push.png b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_push.png deleted file mode 100644 index 7caf4d72..00000000 Binary files a/docs-en/chapter_stack_and_queue/stack.assets/array_stack_push.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step1.png b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step1.png new file mode 100644 index 00000000..0cbbb17d Binary files /dev/null and b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step1.png differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step2_push.png b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step2_push.png new file mode 100644 index 00000000..b5862c7a Binary files /dev/null and b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step2_push.png differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step3_pop.png b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step3_pop.png new file mode 100644 index 00000000..4b884399 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/stack.assets/array_stack_step3_pop.png differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack.png b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack.png deleted file mode 100644 index 5821ca82..00000000 Binary files a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_pop.png b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_pop.png deleted file mode 100644 index 09a57488..00000000 Binary files a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_pop.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_push.png b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_push.png deleted file mode 100644 index b4605318..00000000 Binary files a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_push.png and /dev/null differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step1.png b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step1.png new file mode 100644 index 00000000..fea1a09b Binary files /dev/null and b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step1.png differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step2_push.png b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step2_push.png new file mode 100644 index 00000000..e97f5aa3 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step2_push.png differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step3_pop.png b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step3_pop.png new file mode 100644 index 00000000..d9ac3825 Binary files /dev/null and b/docs-en/chapter_stack_and_queue/stack.assets/linkedlist_stack_step3_pop.png differ diff --git a/docs-en/chapter_stack_and_queue/stack.assets/stack_operations.png b/docs-en/chapter_stack_and_queue/stack.assets/stack_operations.png index f28a5fbc..81484f74 100644 Binary files a/docs-en/chapter_stack_and_queue/stack.assets/stack_operations.png and b/docs-en/chapter_stack_and_queue/stack.assets/stack_operations.png differ diff --git a/docs-en/chapter_stack_and_queue/stack.md b/docs-en/chapter_stack_and_queue/stack.md index b53b84de..68b24f72 100755 --- a/docs-en/chapter_stack_and_queue/stack.md +++ b/docs-en/chapter_stack_and_queue/stack.md @@ -319,13 +319,13 @@ When implementing a stack using a linked list, we can consider the head node of As shown in the figure below, for the push operation, we simply insert elements at the head of the linked list. This method of node insertion is known as "head insertion." For the pop operation, we just need to remove the head node from the list. === "LinkedListStack" - ![Implementing Stack with Linked List for Push and Pop Operations](stack.assets/linkedlist_stack.png) + ![Implementing Stack with Linked List for Push and Pop Operations](stack.assets/linkedlist_stack_step1.png) === "push()" - ![linkedlist_stack_push](stack.assets/linkedlist_stack_push.png) + ![linkedlist_stack_push](stack.assets/linkedlist_stack_step2_push.png) === "pop()" - ![linkedlist_stack_pop](stack.assets/linkedlist_stack_pop.png) + ![linkedlist_stack_pop](stack.assets/linkedlist_stack_step3_pop.png) Below is an example code for implementing a stack based on a linked list: @@ -338,13 +338,13 @@ Below is an example code for implementing a stack based on a linked list: When implementing a stack using an array, we can consider the end of the array as the top of the stack. As shown in the figure below, push and pop operations correspond to adding and removing elements at the end of the array, respectively, both with a time complexity of $O(1)$. === "ArrayStack" - ![Implementing Stack with Array for Push and Pop Operations](stack.assets/array_stack.png) + ![Implementing Stack with Array for Push and Pop Operations](stack.assets/array_stack_step1.png) === "push()" - ![array_stack_push](stack.assets/array_stack_push.png) + ![array_stack_push](stack.assets/array_stack_step2_push.png) === "pop()" - ![array_stack_pop](stack.assets/array_stack_pop.png) + ![array_stack_pop](stack.assets/array_stack_step3_pop.png) Since the elements to be pushed onto the stack may continuously increase, we can use a dynamic array, thus avoiding the need to handle array expansion ourselves. Here is an example code: