mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-15 22:57:48 +08:00
Add animation player (#1877)
* Add auto slide controller. * Fix the animation blocks. * renamed as animation_player * Bug fixes * Refine animation player controls
This commit is contained in:
@@ -365,13 +365,13 @@ When implementing a stack using a linked list, we can treat the head node of the
|
||||
|
||||
As shown in the figure below, for the push operation, we simply insert an element at the head of the linked list. This node insertion method is called the "head insertion method." For the pop operation, we just need to remove the head node from the linked list.
|
||||
|
||||
=== "LinkedListStack"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "push()"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "pop()"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
Below is sample code for implementing a stack based on a linked list:
|
||||
@@ -384,13 +384,13 @@ Below is sample code for implementing a stack based on a linked list:
|
||||
|
||||
When implementing a stack using an array, we can treat 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, both with a time complexity of $O(1)$.
|
||||
|
||||
=== "ArrayStack"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "push()"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "pop()"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
Since elements pushed onto the stack may increase continuously, we can use a dynamic array, which eliminates the need to handle array expansion ourselves. Here is the sample code:
|
||||
|
||||
Reference in New Issue
Block a user