mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-30 20:07:14 +00:00
deploy
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
|
||||
<title>1.2 What is an algorithm - Hello Algo</title>
|
||||
<title>1.2 What Is an Algorithm - Hello Algo</title>
|
||||
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
|
||||
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
|
||||
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback">
|
||||
<style>:root{--md-text-font:"Lato";--md-code-font:"JetBrains Mono"}</style>
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
<div class="md-header__topic" data-md-component="header-topic">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
1.2 What is an algorithm
|
||||
1.2 What Is an Algorithm
|
||||
|
||||
</span>
|
||||
</div>
|
||||
@@ -371,7 +371,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Before starting
|
||||
Before Starting
|
||||
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Before starting
|
||||
Before Starting
|
||||
|
||||
|
||||
</label>
|
||||
@@ -487,7 +487,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
0.1 About this book
|
||||
0.1 About This Book
|
||||
|
||||
|
||||
|
||||
@@ -515,7 +515,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
0.2 How to read
|
||||
0.2 How to Use This Book
|
||||
|
||||
|
||||
|
||||
@@ -606,7 +606,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 1. Encounter with algorithms
|
||||
Chapter 1. Encounter With Algorithms
|
||||
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 1. Encounter with algorithms
|
||||
Chapter 1. Encounter With Algorithms
|
||||
|
||||
|
||||
</label>
|
||||
@@ -650,7 +650,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
1.1 Algorithms are everywhere
|
||||
1.1 Algorithms Are Everywhere
|
||||
|
||||
|
||||
|
||||
@@ -687,7 +687,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
1.2 What is an algorithm
|
||||
1.2 What Is an Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -705,7 +705,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
1.2 What is an algorithm
|
||||
1.2 What Is an Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -731,10 +731,10 @@
|
||||
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#121-definition-of-an-algorithm" class="md-nav__link">
|
||||
<a href="#121-algorithm-definition" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
1.2.1 Definition of an algorithm
|
||||
1.2.1 Algorithm Definition
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -742,10 +742,10 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#122-definition-of-a-data-structure" class="md-nav__link">
|
||||
<a href="#122-data-structure-definition" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
1.2.2 Definition of a data structure
|
||||
1.2.2 Data Structure Definition
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -753,10 +753,10 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#123-relationship-between-data-structures-and-algorithms" class="md-nav__link">
|
||||
<a href="#123-the-relationship-between-data-structures-and-algorithms" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
1.2.3 Relationship between data structures and algorithms
|
||||
1.2.3 The Relationship Between Data Structures and Algorithms
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -851,7 +851,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 2. Complexity analysis
|
||||
Chapter 2. Complexity Analysis
|
||||
|
||||
|
||||
|
||||
@@ -873,7 +873,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 2. Complexity analysis
|
||||
Chapter 2. Complexity Analysis
|
||||
|
||||
|
||||
</label>
|
||||
@@ -895,7 +895,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.1 Algorithm efficiency assessment
|
||||
2.1 Algorithm Efficiency Evaluation
|
||||
|
||||
|
||||
|
||||
@@ -923,7 +923,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.2 Iteration and recursion
|
||||
2.2 Iteration and Recursion
|
||||
|
||||
|
||||
|
||||
@@ -951,7 +951,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.3 Time complexity
|
||||
2.3 Time Complexity
|
||||
|
||||
|
||||
|
||||
@@ -979,7 +979,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.4 Space complexity
|
||||
2.4 Space Complexity
|
||||
|
||||
|
||||
|
||||
@@ -1072,7 +1072,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 3. Data structures
|
||||
Chapter 3. Data Structures
|
||||
|
||||
|
||||
|
||||
@@ -1094,7 +1094,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 3. Data structures
|
||||
Chapter 3. Data Structures
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1116,7 +1116,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.1 Classification of data structures
|
||||
3.1 Classification of Data Structures
|
||||
|
||||
|
||||
|
||||
@@ -1144,7 +1144,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.2 Basic data types
|
||||
3.2 Basic Data Types
|
||||
|
||||
|
||||
|
||||
@@ -1172,7 +1172,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.3 Number encoding *
|
||||
3.3 Number Encoding *
|
||||
|
||||
|
||||
|
||||
@@ -1200,7 +1200,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.4 Character encoding *
|
||||
3.4 Character Encoding *
|
||||
|
||||
|
||||
|
||||
@@ -1293,7 +1293,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 4. Array and linked list
|
||||
Chapter 4. Array and Linked List
|
||||
|
||||
|
||||
|
||||
@@ -1315,7 +1315,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 4. Array and linked list
|
||||
Chapter 4. Array and Linked List
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1365,7 +1365,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
4.2 Linked list
|
||||
4.2 Linked List
|
||||
|
||||
|
||||
|
||||
@@ -1421,7 +1421,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
4.4 Memory and cache *
|
||||
4.4 Memory and Cache *
|
||||
|
||||
|
||||
|
||||
@@ -1512,7 +1512,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 5. Stack and queue
|
||||
Chapter 5. Stack and Queue
|
||||
|
||||
|
||||
|
||||
@@ -1534,7 +1534,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 5. Stack and queue
|
||||
Chapter 5. Stack and Queue
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1612,7 +1612,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
5.3 Double-ended queue
|
||||
5.3 Double-Ended Queue
|
||||
|
||||
|
||||
|
||||
@@ -1703,7 +1703,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 6. Hash table
|
||||
Chapter 6. Hashing
|
||||
|
||||
|
||||
|
||||
@@ -1725,7 +1725,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 6. Hash table
|
||||
Chapter 6. Hashing
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1747,7 +1747,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
6.1 Hash table
|
||||
6.1 Hash Table
|
||||
|
||||
|
||||
|
||||
@@ -1775,7 +1775,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
6.2 Hash collision
|
||||
6.2 Hash Collision
|
||||
|
||||
|
||||
|
||||
@@ -1803,7 +1803,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
6.3 Hash algorithm
|
||||
6.3 Hash Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -1942,7 +1942,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.1 Binary tree
|
||||
7.1 Binary Tree
|
||||
|
||||
|
||||
|
||||
@@ -1970,7 +1970,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.2 Binary tree traversal
|
||||
7.2 Binary Tree Traversal
|
||||
|
||||
|
||||
|
||||
@@ -1998,7 +1998,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.3 Array Representation of tree
|
||||
7.3 Array Representation of Tree
|
||||
|
||||
|
||||
|
||||
@@ -2026,7 +2026,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.4 Binary Search tree
|
||||
7.4 Binary Search Tree
|
||||
|
||||
|
||||
|
||||
@@ -2054,7 +2054,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.5 AVL tree *
|
||||
7.5 AVL Tree *
|
||||
|
||||
|
||||
|
||||
@@ -2217,7 +2217,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
8.2 Building a heap
|
||||
8.2 Building a Heap
|
||||
|
||||
|
||||
|
||||
@@ -2245,7 +2245,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
8.3 Top-k problem
|
||||
8.3 Top-K Problem
|
||||
|
||||
|
||||
|
||||
@@ -2408,7 +2408,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
9.2 Basic graph operations
|
||||
9.2 Basic Operations on Graphs
|
||||
|
||||
|
||||
|
||||
@@ -2436,7 +2436,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
9.3 Graph traversal
|
||||
9.3 Graph Traversal
|
||||
|
||||
|
||||
|
||||
@@ -2575,7 +2575,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.1 Binary search
|
||||
10.1 Binary Search
|
||||
|
||||
|
||||
|
||||
@@ -2603,7 +2603,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.2 Binary search insertion
|
||||
10.2 Binary Search Insertion
|
||||
|
||||
|
||||
|
||||
@@ -2631,7 +2631,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.3 Binary search boundaries
|
||||
10.3 Binary Search Edge Cases
|
||||
|
||||
|
||||
|
||||
@@ -2659,7 +2659,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.4 Hashing optimization strategies
|
||||
10.4 Hash Optimization Strategy
|
||||
|
||||
|
||||
|
||||
@@ -2687,7 +2687,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.5 Search algorithms revisited
|
||||
10.5 Search Algorithms Revisited
|
||||
|
||||
|
||||
|
||||
@@ -2836,7 +2836,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.1 Sorting algorithms
|
||||
11.1 Sorting Algorithms
|
||||
|
||||
|
||||
|
||||
@@ -2864,7 +2864,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.2 Selection sort
|
||||
11.2 Selection Sort
|
||||
|
||||
|
||||
|
||||
@@ -2892,7 +2892,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.3 Bubble sort
|
||||
11.3 Bubble Sort
|
||||
|
||||
|
||||
|
||||
@@ -2920,7 +2920,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.4 Insertion sort
|
||||
11.4 Insertion Sort
|
||||
|
||||
|
||||
|
||||
@@ -2948,7 +2948,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.5 Quick sort
|
||||
11.5 Quick Sort
|
||||
|
||||
|
||||
|
||||
@@ -2976,7 +2976,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.6 Merge sort
|
||||
11.6 Merge Sort
|
||||
|
||||
|
||||
|
||||
@@ -3004,7 +3004,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.7 Heap sort
|
||||
11.7 Heap Sort
|
||||
|
||||
|
||||
|
||||
@@ -3032,7 +3032,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.8 Bucket sort
|
||||
11.8 Bucket Sort
|
||||
|
||||
|
||||
|
||||
@@ -3060,7 +3060,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.9 Counting sort
|
||||
11.9 Counting Sort
|
||||
|
||||
|
||||
|
||||
@@ -3088,7 +3088,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.10 Radix sort
|
||||
11.10 Radix Sort
|
||||
|
||||
|
||||
|
||||
@@ -3181,7 +3181,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 12. Divide and conquer
|
||||
Chapter 12. Divide and Conquer
|
||||
|
||||
|
||||
|
||||
@@ -3203,7 +3203,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 12. Divide and conquer
|
||||
Chapter 12. Divide and Conquer
|
||||
|
||||
|
||||
</label>
|
||||
@@ -3225,7 +3225,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.1 Divide and conquer algorithms
|
||||
12.1 Divide and Conquer Algorithms
|
||||
|
||||
|
||||
|
||||
@@ -3253,7 +3253,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.2 Divide and conquer search strategy
|
||||
12.2 Divide and Conquer Search Strategy
|
||||
|
||||
|
||||
|
||||
@@ -3281,7 +3281,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.3 Building binary tree problem
|
||||
12.3 Building a Binary Tree Problem
|
||||
|
||||
|
||||
|
||||
@@ -3309,7 +3309,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.4 Tower of Hanoi Problem
|
||||
12.4 Hanoi Tower Problem
|
||||
|
||||
|
||||
|
||||
@@ -3446,7 +3446,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.1 Backtracking algorithms
|
||||
13.1 Backtracking Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -3474,7 +3474,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.2 Permutation problem
|
||||
13.2 Permutations Problem
|
||||
|
||||
|
||||
|
||||
@@ -3502,7 +3502,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.3 Subset sum problem
|
||||
13.3 Subset-Sum Problem
|
||||
|
||||
|
||||
|
||||
@@ -3530,7 +3530,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.4 n queens problem
|
||||
13.4 N-Queens Problem
|
||||
|
||||
|
||||
|
||||
@@ -3627,7 +3627,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 14. Dynamic programming
|
||||
Chapter 14. Dynamic Programming
|
||||
|
||||
|
||||
|
||||
@@ -3649,7 +3649,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 14. Dynamic programming
|
||||
Chapter 14. Dynamic Programming
|
||||
|
||||
|
||||
</label>
|
||||
@@ -3671,7 +3671,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.1 Introduction to dynamic programming
|
||||
14.1 Introduction to Dynamic Programming
|
||||
|
||||
|
||||
|
||||
@@ -3699,7 +3699,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.2 Characteristics of DP problems
|
||||
14.2 Characteristics of Dynamic Programming Problems
|
||||
|
||||
|
||||
|
||||
@@ -3727,7 +3727,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.3 DP problem-solving approach¶
|
||||
14.3 Dynamic Programming Problem-Solving Approach
|
||||
|
||||
|
||||
|
||||
@@ -3755,7 +3755,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.4 0-1 Knapsack problem
|
||||
14.4 0-1 Knapsack Problem
|
||||
|
||||
|
||||
|
||||
@@ -3783,7 +3783,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.5 Unbounded knapsack problem
|
||||
14.5 Unbounded Knapsack Problem
|
||||
|
||||
|
||||
|
||||
@@ -3811,7 +3811,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.6 Edit distance problem
|
||||
14.6 Edit Distance Problem
|
||||
|
||||
|
||||
|
||||
@@ -3948,7 +3948,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.1 Greedy algorithms
|
||||
15.1 Greedy Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -3976,7 +3976,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.2 Fractional knapsack problem
|
||||
15.2 Fractional Knapsack Problem
|
||||
|
||||
|
||||
|
||||
@@ -4004,7 +4004,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.3 Maximum capacity problem
|
||||
15.3 Maximum Capacity Problem
|
||||
|
||||
|
||||
|
||||
@@ -4032,7 +4032,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.4 Maximum product cutting problem
|
||||
15.4 Maximum Product Cutting Problem
|
||||
|
||||
|
||||
|
||||
@@ -4165,7 +4165,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
16.1 Installation
|
||||
16.1 Programming Environment Installation
|
||||
|
||||
|
||||
|
||||
@@ -4193,7 +4193,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
16.2 Contributing
|
||||
16.2 Contributing Together
|
||||
|
||||
|
||||
|
||||
@@ -4221,7 +4221,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
16.3 Terminology
|
||||
16.3 Terminology Table
|
||||
|
||||
|
||||
|
||||
@@ -4335,10 +4335,10 @@
|
||||
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#121-definition-of-an-algorithm" class="md-nav__link">
|
||||
<a href="#121-algorithm-definition" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
1.2.1 Definition of an algorithm
|
||||
1.2.1 Algorithm Definition
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -4346,10 +4346,10 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#122-definition-of-a-data-structure" class="md-nav__link">
|
||||
<a href="#122-data-structure-definition" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
1.2.2 Definition of a data structure
|
||||
1.2.2 Data Structure Definition
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -4357,10 +4357,10 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#123-relationship-between-data-structures-and-algorithms" class="md-nav__link">
|
||||
<a href="#123-the-relationship-between-data-structures-and-algorithms" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
1.2.3 Relationship between data structures and algorithms
|
||||
1.2.3 The Relationship Between Data Structures and Algorithms
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -4404,75 +4404,75 @@
|
||||
|
||||
|
||||
<!-- Page content -->
|
||||
<h1 id="12-what-is-an-algorithm">1.2 What is an algorithm<a class="headerlink" href="#12-what-is-an-algorithm" title="Permanent link">¶</a></h1>
|
||||
<h2 id="121-definition-of-an-algorithm">1.2.1 Definition of an algorithm<a class="headerlink" href="#121-definition-of-an-algorithm" title="Permanent link">¶</a></h2>
|
||||
<p>An <u>algorithm</u> is a set of instructions or steps to solve a specific problem within a finite amount of time. It has the following characteristics:</p>
|
||||
<h1 id="12-what-is-an-algorithm">1.2 What Is an Algorithm<a class="headerlink" href="#12-what-is-an-algorithm" title="Permanent link">¶</a></h1>
|
||||
<h2 id="121-algorithm-definition">1.2.1 Algorithm Definition<a class="headerlink" href="#121-algorithm-definition" title="Permanent link">¶</a></h2>
|
||||
<p>An <u>algorithm</u> is a set of instructions or operational steps that solves a specific problem within a finite amount of time. It has the following characteristics.</p>
|
||||
<ul>
|
||||
<li>The problem is clearly defined, including unambiguous definitions of input and output.</li>
|
||||
<li>The algorithm is feasible, meaning it can be completed within a finite number of steps, time, and memory space.</li>
|
||||
<li>Each step has a definitive meaning. The output is consistently the same under the same inputs and conditions.</li>
|
||||
<li>The problem is well-defined, with clear input and output definitions.</li>
|
||||
<li>It is feasible and can be completed within a finite number of steps, time, and memory space.</li>
|
||||
<li>Each step has a definite meaning, and under the same input and operating conditions, the output is always the same.</li>
|
||||
</ul>
|
||||
<h2 id="122-definition-of-a-data-structure">1.2.2 Definition of a data structure<a class="headerlink" href="#122-definition-of-a-data-structure" title="Permanent link">¶</a></h2>
|
||||
<p>A <u>data structure</u> is a way of organizing and storing data in a computer, with the following design goals:</p>
|
||||
<h2 id="122-data-structure-definition">1.2.2 Data Structure Definition<a class="headerlink" href="#122-data-structure-definition" title="Permanent link">¶</a></h2>
|
||||
<p>A <u>data structure</u> is a way of organizing and storing data, covering the data content, relationships between data, and methods for data operations. It has the following design objectives.</p>
|
||||
<ul>
|
||||
<li>Minimize space occupancy to save computer memory.</li>
|
||||
<li>Make data operations as fast as possible, covering data access, addition, deletion, updating, etc.</li>
|
||||
<li>Provide concise data representation and logical information to enable efficient algorithm execution.</li>
|
||||
<li>Occupy as little space as possible to save computer memory.</li>
|
||||
<li>Data operations should be as fast as possible, covering data access, addition, deletion, update, etc.</li>
|
||||
<li>Provide a concise data representation and logical information so that algorithms can run efficiently.</li>
|
||||
</ul>
|
||||
<p><strong>Designing data structures is a balancing act, often requiring trade-offs</strong>. If you want to improve in one aspect, you often need to compromise in another. Here are two examples:</p>
|
||||
<p><strong>Data structure design is a process full of trade-offs</strong>. If we want to achieve improvements in one aspect, we often need to make compromises in another aspect. Here are two examples.</p>
|
||||
<ul>
|
||||
<li>Compared to arrays, linked lists offer more convenience in data addition and deletion but sacrifice data access speed.</li>
|
||||
<li>Compared with linked lists, graphs provide richer logical information but require more memory space.</li>
|
||||
<li>Compared to arrays, linked lists are more convenient for data addition and deletion operations but sacrifice data access speed.</li>
|
||||
<li>Compared to linked lists, graphs provide richer logical information but require larger memory space.</li>
|
||||
</ul>
|
||||
<h2 id="123-relationship-between-data-structures-and-algorithms">1.2.3 Relationship between data structures and algorithms<a class="headerlink" href="#123-relationship-between-data-structures-and-algorithms" title="Permanent link">¶</a></h2>
|
||||
<p>As shown in Figure 1-4, data structures and algorithms are highly related and closely integrated, specifically in the following three aspects:</p>
|
||||
<h2 id="123-the-relationship-between-data-structures-and-algorithms">1.2.3 The Relationship Between Data Structures and Algorithms<a class="headerlink" href="#123-the-relationship-between-data-structures-and-algorithms" title="Permanent link">¶</a></h2>
|
||||
<p>As shown in Figure 1-4, data structures and algorithms are highly related and tightly coupled, specifically manifested in the following three aspects.</p>
|
||||
<ul>
|
||||
<li>Data structures are the foundation of algorithms. They provide structured data storage and methods for manipulating data for algorithms.</li>
|
||||
<li>Algorithms inject vitality into data structures. The data structure alone only stores data information; it is through the application of algorithms that specific problems can be solved.</li>
|
||||
<li>Algorithms can often be implemented based on different data structures, but their execution efficiency can vary greatly. Choosing the right data structure is key.</li>
|
||||
<li>Data structures are the foundation of algorithms. Data structures provide algorithms with structured storage of data and methods for operating on data.</li>
|
||||
<li>Algorithms breathe life into data structures. Data structures themselves only store data information; combined with algorithms, they can solve specific problems.</li>
|
||||
<li>Algorithms can usually be implemented based on different data structures, but execution efficiency may vary greatly. Choosing the appropriate data structure is key.</li>
|
||||
</ul>
|
||||
<p><a class="glightbox" href="../what_is_dsa.assets/relationship_between_data_structure_and_algorithm.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Relationship between data structures and algorithms" class="animation-figure" src="../what_is_dsa.assets/relationship_between_data_structure_and_algorithm.png" /></a></p>
|
||||
<p align="center"> Figure 1-4 Relationship between data structures and algorithms </p>
|
||||
<p><a class="glightbox" href="../what_is_dsa.assets/relationship_between_data_structure_and_algorithm.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="The relationship between data structures and algorithms" class="animation-figure" src="../what_is_dsa.assets/relationship_between_data_structure_and_algorithm.png" /></a></p>
|
||||
<p align="center"> Figure 1-4 The relationship between data structures and algorithms </p>
|
||||
|
||||
<p>Data structures and algorithms can be likened to a set of building blocks, as illustrated in Figure 1-5. A building block set includes numerous pieces, accompanied by detailed assembly instructions. Following these instructions step by step allows us to construct an intricate block model.</p>
|
||||
<p>Data structures and algorithms are like assembling building blocks as shown in Figure 1-5. A set of building blocks, in addition to containing many parts, also comes with detailed assembly instructions. By following the instructions step by step, we can assemble an exquisite building block model.</p>
|
||||
<p><a class="glightbox" href="../what_is_dsa.assets/assembling_blocks.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Assembling blocks" class="animation-figure" src="../what_is_dsa.assets/assembling_blocks.png" /></a></p>
|
||||
<p align="center"> Figure 1-5 Assembling blocks </p>
|
||||
|
||||
<p>The detailed correspondence between the two is shown in Table 1-1.</p>
|
||||
<p align="center"> Table 1-1 Comparing data structures and algorithms to building blocks </p>
|
||||
<p align="center"> Table 1-1 Comparing data structures and algorithms to assembling building blocks </p>
|
||||
|
||||
<div class="center-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data Structures and Algorithms</th>
|
||||
<th>Building Blocks</th>
|
||||
<th>Data structures and algorithms</th>
|
||||
<th>Assembling building blocks</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Input data</td>
|
||||
<td>Unassembled blocks</td>
|
||||
<td>Unassembled building blocks</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Data structure</td>
|
||||
<td>Organization of blocks, including shape, size, connections, etc</td>
|
||||
<td>Organization form of building blocks, including shape, size, connection method, etc.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Algorithm</td>
|
||||
<td>A series of steps to assemble the blocks into the desired shape</td>
|
||||
<td>A series of operational steps to assemble the blocks into the target form</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Output data</td>
|
||||
<td>Completed Block model</td>
|
||||
<td>Building block model</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p>It's worth noting that data structures and algorithms are independent of programming languages. For this reason, this book is able to provide implementations in multiple programming languages.</p>
|
||||
<p>It is worth noting that data structures and algorithms are independent of programming languages. For this reason, this book is able to provide implementations based on multiple programming languages.</p>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Conventional Abbreviation</p>
|
||||
<p>In real-life discussions, we often refer to "Data Structures and Algorithms" simply as "Algorithms". For example, the well-known LeetCode algorithm questions actually test knowledge of both data structures and algorithms.</p>
|
||||
<p class="admonition-title">Conventional abbreviation</p>
|
||||
<p>In actual discussions, we usually abbreviate "data structures and algorithms" as "algorithms". For example, the well-known LeetCode algorithm problems actually examine knowledge of both data structures and algorithms.</p>
|
||||
</div>
|
||||
|
||||
<!-- Source file information -->
|
||||
@@ -4496,7 +4496,7 @@ aria-label="Footer"
|
||||
<a
|
||||
href="../algorithms_are_everywhere/"
|
||||
class="md-footer__link md-footer__link--prev"
|
||||
aria-label="Previous: 1.1 Algorithms are everywhere"
|
||||
aria-label="Previous: 1.1 Algorithms Are Everywhere"
|
||||
rel="prev"
|
||||
>
|
||||
<div class="md-footer__button md-icon">
|
||||
@@ -4508,7 +4508,7 @@ aria-label="Footer"
|
||||
Previous
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
1.1 Algorithms are everywhere
|
||||
1.1 Algorithms Are Everywhere
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@@ -4621,7 +4621,7 @@ aria-label="Footer"
|
||||
<nav class="md-footer__inner md-grid" aria-label="Footer" >
|
||||
|
||||
|
||||
<a href="../algorithms_are_everywhere/" class="md-footer__link md-footer__link--prev" aria-label="Previous: 1.1 Algorithms are everywhere">
|
||||
<a href="../algorithms_are_everywhere/" class="md-footer__link md-footer__link--prev" aria-label="Previous: 1.1 Algorithms Are Everywhere">
|
||||
<div class="md-footer__button md-icon">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
|
||||
@@ -4631,7 +4631,7 @@ aria-label="Footer"
|
||||
Previous
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
1.1 Algorithms are everywhere
|
||||
1.1 Algorithms Are Everywhere
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user