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

@ -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: