mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-26 02:26:28 +08:00
build
This commit is contained in:
parent
a0f7d7fcca
commit
3fdebdd4b2
4 changed files with 23 additions and 23 deletions
|
@ -30,7 +30,7 @@ The main content of the book is shown in the following figure.
|
|||
- **Data Structures**: focuses on fundamental data types, classification methods, definitions, pros and cons, common operations, types, applications, and implementation methods of data structures such as array, linked list, stack, queue, hash table, tree, heap, graph, etc.
|
||||
- **Algorithms**: defines algorithms, discusses their pros and cons, efficiency, application scenarios, problem-solving steps, and includes sample questions for various algorithms such as search, sorting, divide and conquer, backtracking, dynamic programming, greedy algorithms, and more.
|
||||
|
||||
![Main Content of the Book](about_the_book.assets/hello_algo_mindmap.jpg){ class="animation-figure" }
|
||||
![Main Content of the Book](about_the_book.assets/hello_algo_mindmap.png){ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 0-1 Main Content of the Book </p>
|
||||
|
||||
|
|
|
@ -358,19 +358,19 @@ For a double-ended queue, both the head and the tail can perform enqueue and deq
|
|||
As shown in the Figure 5-8 , 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){ class="animation-figure" }
|
||||
![Implementing Double-Ended Queue with Doubly Linked List for Enqueue and Dequeue Operations](deque.assets/linkedlist_deque_step1.png){ class="animation-figure" }
|
||||
|
||||
=== "pushLast()"
|
||||
![linkedlist_deque_push_last](deque.assets/linkedlist_deque_push_last.png){ class="animation-figure" }
|
||||
![linkedlist_deque_push_last](deque.assets/linkedlist_deque_step2_push_last.png){ class="animation-figure" }
|
||||
|
||||
=== "pushFirst()"
|
||||
![linkedlist_deque_push_first](deque.assets/linkedlist_deque_push_first.png){ class="animation-figure" }
|
||||
![linkedlist_deque_push_first](deque.assets/linkedlist_deque_step3_push_first.png){ class="animation-figure" }
|
||||
|
||||
=== "popLast()"
|
||||
![linkedlist_deque_pop_last](deque.assets/linkedlist_deque_pop_last.png){ class="animation-figure" }
|
||||
![linkedlist_deque_pop_last](deque.assets/linkedlist_deque_step4_pop_last.png){ class="animation-figure" }
|
||||
|
||||
=== "popFirst()"
|
||||
![linkedlist_deque_pop_first](deque.assets/linkedlist_deque_pop_first.png){ class="animation-figure" }
|
||||
![linkedlist_deque_pop_first](deque.assets/linkedlist_deque_step5_pop_first.png){ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 5-8 Implementing Double-Ended Queue with Doubly Linked List for Enqueue and Dequeue Operations </p>
|
||||
|
||||
|
@ -1996,19 +1996,19 @@ The implementation code is as follows:
|
|||
As shown in the Figure 5-9 , 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){ class="animation-figure" }
|
||||
![Implementing Double-Ended Queue with Array for Enqueue and Dequeue Operations](deque.assets/array_deque_step1.png){ class="animation-figure" }
|
||||
|
||||
=== "pushLast()"
|
||||
![array_deque_push_last](deque.assets/array_deque_push_last.png){ class="animation-figure" }
|
||||
![array_deque_push_last](deque.assets/array_deque_step2_push_last.png){ class="animation-figure" }
|
||||
|
||||
=== "pushFirst()"
|
||||
![array_deque_push_first](deque.assets/array_deque_push_first.png){ class="animation-figure" }
|
||||
![array_deque_push_first](deque.assets/array_deque_step3_push_first.png){ class="animation-figure" }
|
||||
|
||||
=== "popLast()"
|
||||
![array_deque_pop_last](deque.assets/array_deque_pop_last.png){ class="animation-figure" }
|
||||
![array_deque_pop_last](deque.assets/array_deque_step4_pop_last.png){ class="animation-figure" }
|
||||
|
||||
=== "popFirst()"
|
||||
![array_deque_pop_first](deque.assets/array_deque_pop_first.png){ class="animation-figure" }
|
||||
![array_deque_pop_first](deque.assets/array_deque_step5_pop_first.png){ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 5-9 Implementing Double-Ended Queue with Array for Enqueue and Dequeue Operations </p>
|
||||
|
||||
|
|
|
@ -332,13 +332,13 @@ To implement a queue, we need a data structure that allows adding elements at on
|
|||
As shown in the Figure 5-5 , 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){ class="animation-figure" }
|
||||
![Implementing Queue with Linked List for Enqueue and Dequeue Operations](queue.assets/linkedlist_queue_step1.png){ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||
![linkedlist_queue_push](queue.assets/linkedlist_queue_push.png){ class="animation-figure" }
|
||||
![linkedlist_queue_push](queue.assets/linkedlist_queue_step2_push.png){ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||
![linkedlist_queue_pop](queue.assets/linkedlist_queue_pop.png){ class="animation-figure" }
|
||||
![linkedlist_queue_pop](queue.assets/linkedlist_queue_step3_pop.png){ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 5-5 Implementing Queue with Linked List for Enqueue and Dequeue Operations </p>
|
||||
|
||||
|
@ -1231,13 +1231,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){ class="animation-figure" }
|
||||
![Implementing Queue with Array for Enqueue and Dequeue Operations](queue.assets/array_queue_step1.png){ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||
![array_queue_push](queue.assets/array_queue_push.png){ class="animation-figure" }
|
||||
![array_queue_push](queue.assets/array_queue_step2_push.png){ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||
![array_queue_pop](queue.assets/array_queue_pop.png){ class="animation-figure" }
|
||||
![array_queue_pop](queue.assets/array_queue_step3_pop.png){ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 5-6 Implementing Queue with Array for Enqueue and Dequeue Operations </p>
|
||||
|
||||
|
|
|
@ -330,13 +330,13 @@ When implementing a stack using a linked list, we can consider the head node of
|
|||
As shown in the Figure 5-2 , 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){ class="animation-figure" }
|
||||
![Implementing Stack with Linked List for Push and Pop Operations](stack.assets/linkedlist_stack_step1.png){ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||
![linkedlist_stack_push](stack.assets/linkedlist_stack_push.png){ class="animation-figure" }
|
||||
![linkedlist_stack_push](stack.assets/linkedlist_stack_step2_push.png){ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||
![linkedlist_stack_pop](stack.assets/linkedlist_stack_pop.png){ class="animation-figure" }
|
||||
![linkedlist_stack_pop](stack.assets/linkedlist_stack_step3_pop.png){ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 5-2 Implementing Stack with Linked List for Push and Pop Operations </p>
|
||||
|
||||
|
@ -1094,13 +1094,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 5-3 , 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){ class="animation-figure" }
|
||||
![Implementing Stack with Array for Push and Pop Operations](stack.assets/array_stack_step1.png){ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||
![array_stack_push](stack.assets/array_stack_push.png){ class="animation-figure" }
|
||||
![array_stack_push](stack.assets/array_stack_step2_push.png){ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||
![array_stack_pop](stack.assets/array_stack_pop.png){ class="animation-figure" }
|
||||
![array_stack_pop](stack.assets/array_stack_step3_pop.png){ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 5-3 Implementing Stack with Array for Push and Pop Operations </p>
|
||||
|
||||
|
|
Loading…
Reference in a new issue