mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-07 23:57:02 +08:00
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:
@ -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"
|
||||

|
||||

|
||||
|
||||
=== "push()"
|
||||

|
||||

|
||||
|
||||
=== "pop()"
|
||||

|
||||

|
||||
|
||||
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"
|
||||

|
||||

|
||||
|
||||
=== "push()"
|
||||

|
||||

|
||||
|
||||
=== "pop()"
|
||||

|
||||

|
||||
|
||||
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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user