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 5f0bcd353..000000000 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 9d203a63f..000000000 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 2c18b17aa..000000000 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 8b7b352e0..000000000 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 6b3baf39d..000000000 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 000000000..e6f3c834e 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 000000000..6d5f96b92 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 000000000..edd2c86e9 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 000000000..c27fda4ef 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 000000000..10c9f605e 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 a39788322..d2413b678 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 d61502010..000000000 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 b50944ef1..000000000 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 8df343375..000000000 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 2cdd94a5a..000000000 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 eed3f18ea..000000000 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 000000000..fa24a79b6 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 000000000..ec4752eae 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 000000000..e84278f57 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 000000000..3d451a879 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 000000000..09ce1f537 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 367a0d586..83e7bb440 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 29c7f4962..000000000 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 c57e6a198..000000000 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 71dcd1d78..000000000 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 000000000..7c0f81570 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 000000000..8c9dd1230 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 000000000..029e6a35e 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 7cff9b1b9..000000000 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 6a43121f6..000000000 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 a53b9f44d..000000000 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 000000000..8b888a3a7 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 000000000..2b4c2731a 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 000000000..4fa752c49 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 ce3a6f2bc..13d9afa25 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 c0dcb90ae..1f3e07b72 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 e8e3445b7..000000000 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 be56b586d..000000000 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 7caf4d72e..000000000 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 000000000..0cbbb17d1 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 000000000..b5862c7ad 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 000000000..4b8843994 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 5821ca82a..000000000 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 09a57488b..000000000 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 b46053185..000000000 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 000000000..fea1a09b2 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 000000000..e97f5aa37 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 000000000..d9ac38251 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 f28a5fbc9..81484f746 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 b53b84de3..68b24f728 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: