mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-07 03:26:39 +08:00
deploy
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
|
||||
<title>3.1 Classification of data structures - Hello Algo</title>
|
||||
<title>3.1 Classification of Data Structures - 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">
|
||||
|
||||
3.1 Classification of data structures
|
||||
3.1 Classification of Data Structures
|
||||
|
||||
</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
|
||||
|
||||
|
||||
|
||||
@@ -604,7 +604,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 1. Encounter with algorithms
|
||||
Chapter 1. Encounter With Algorithms
|
||||
|
||||
|
||||
|
||||
@@ -626,7 +626,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 1. Encounter with algorithms
|
||||
Chapter 1. Encounter With Algorithms
|
||||
|
||||
|
||||
</label>
|
||||
@@ -648,7 +648,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
1.1 Algorithms are everywhere
|
||||
1.1 Algorithms Are Everywhere
|
||||
|
||||
|
||||
|
||||
@@ -676,7 +676,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
1.2 What is an algorithm
|
||||
1.2 What Is an Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -769,7 +769,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 2. Complexity analysis
|
||||
Chapter 2. Complexity Analysis
|
||||
|
||||
|
||||
|
||||
@@ -791,7 +791,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 2. Complexity analysis
|
||||
Chapter 2. Complexity Analysis
|
||||
|
||||
|
||||
</label>
|
||||
@@ -813,7 +813,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.1 Algorithm efficiency assessment
|
||||
2.1 Algorithm Efficiency Evaluation
|
||||
|
||||
|
||||
|
||||
@@ -841,7 +841,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.2 Iteration and recursion
|
||||
2.2 Iteration and Recursion
|
||||
|
||||
|
||||
|
||||
@@ -869,7 +869,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.3 Time complexity
|
||||
2.3 Time Complexity
|
||||
|
||||
|
||||
|
||||
@@ -897,7 +897,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
2.4 Space complexity
|
||||
2.4 Space Complexity
|
||||
|
||||
|
||||
|
||||
@@ -992,7 +992,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 3. Data structures
|
||||
Chapter 3. Data Structures
|
||||
|
||||
|
||||
|
||||
@@ -1014,7 +1014,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 3. Data structures
|
||||
Chapter 3. Data Structures
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1045,7 +1045,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.1 Classification of data structures
|
||||
3.1 Classification of Data Structures
|
||||
|
||||
|
||||
|
||||
@@ -1063,7 +1063,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.1 Classification of data structures
|
||||
3.1 Classification of Data Structures
|
||||
|
||||
|
||||
|
||||
@@ -1092,7 +1092,7 @@
|
||||
<a href="#311-logical-structure-linear-and-non-linear" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
3.1.1 Logical structure: linear and non-linear
|
||||
3.1.1 Logical Structure: Linear and Non-Linear
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -1103,7 +1103,7 @@
|
||||
<a href="#312-physical-structure-contiguous-and-dispersed" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
3.1.2 Physical structure: contiguous and dispersed
|
||||
3.1.2 Physical Structure: Contiguous and Dispersed
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -1133,7 +1133,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.2 Basic data types
|
||||
3.2 Basic Data Types
|
||||
|
||||
|
||||
|
||||
@@ -1161,7 +1161,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.3 Number encoding *
|
||||
3.3 Number Encoding *
|
||||
|
||||
|
||||
|
||||
@@ -1189,7 +1189,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
3.4 Character encoding *
|
||||
3.4 Character Encoding *
|
||||
|
||||
|
||||
|
||||
@@ -1282,7 +1282,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 4. Array and linked list
|
||||
Chapter 4. Array and Linked List
|
||||
|
||||
|
||||
|
||||
@@ -1304,7 +1304,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 4. Array and linked list
|
||||
Chapter 4. Array and Linked List
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1354,7 +1354,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
4.2 Linked list
|
||||
4.2 Linked List
|
||||
|
||||
|
||||
|
||||
@@ -1410,7 +1410,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
4.4 Memory and cache *
|
||||
4.4 Memory and Cache *
|
||||
|
||||
|
||||
|
||||
@@ -1501,7 +1501,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 5. Stack and queue
|
||||
Chapter 5. Stack and Queue
|
||||
|
||||
|
||||
|
||||
@@ -1523,7 +1523,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 5. Stack and queue
|
||||
Chapter 5. Stack and Queue
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1601,7 +1601,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
5.3 Double-ended queue
|
||||
5.3 Double-Ended Queue
|
||||
|
||||
|
||||
|
||||
@@ -1692,7 +1692,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 6. Hash table
|
||||
Chapter 6. Hashing
|
||||
|
||||
|
||||
|
||||
@@ -1714,7 +1714,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 6. Hash table
|
||||
Chapter 6. Hashing
|
||||
|
||||
|
||||
</label>
|
||||
@@ -1736,7 +1736,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
6.1 Hash table
|
||||
6.1 Hash Table
|
||||
|
||||
|
||||
|
||||
@@ -1764,7 +1764,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
6.2 Hash collision
|
||||
6.2 Hash Collision
|
||||
|
||||
|
||||
|
||||
@@ -1792,7 +1792,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
6.3 Hash algorithm
|
||||
6.3 Hash Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -1931,7 +1931,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.1 Binary tree
|
||||
7.1 Binary Tree
|
||||
|
||||
|
||||
|
||||
@@ -1959,7 +1959,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.2 Binary tree traversal
|
||||
7.2 Binary Tree Traversal
|
||||
|
||||
|
||||
|
||||
@@ -1987,7 +1987,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.3 Array Representation of tree
|
||||
7.3 Array Representation of Tree
|
||||
|
||||
|
||||
|
||||
@@ -2015,7 +2015,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.4 Binary Search tree
|
||||
7.4 Binary Search Tree
|
||||
|
||||
|
||||
|
||||
@@ -2043,7 +2043,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
7.5 AVL tree *
|
||||
7.5 AVL Tree *
|
||||
|
||||
|
||||
|
||||
@@ -2206,7 +2206,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
8.2 Building a heap
|
||||
8.2 Building a Heap
|
||||
|
||||
|
||||
|
||||
@@ -2234,7 +2234,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
8.3 Top-k problem
|
||||
8.3 Top-K Problem
|
||||
|
||||
|
||||
|
||||
@@ -2397,7 +2397,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
9.2 Basic graph operations
|
||||
9.2 Basic Operations on Graphs
|
||||
|
||||
|
||||
|
||||
@@ -2425,7 +2425,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
9.3 Graph traversal
|
||||
9.3 Graph Traversal
|
||||
|
||||
|
||||
|
||||
@@ -2564,7 +2564,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.1 Binary search
|
||||
10.1 Binary Search
|
||||
|
||||
|
||||
|
||||
@@ -2592,7 +2592,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.2 Binary search insertion
|
||||
10.2 Binary Search Insertion
|
||||
|
||||
|
||||
|
||||
@@ -2620,7 +2620,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.3 Binary search boundaries
|
||||
10.3 Binary Search Edge Cases
|
||||
|
||||
|
||||
|
||||
@@ -2648,7 +2648,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.4 Hashing optimization strategies
|
||||
10.4 Hash Optimization Strategy
|
||||
|
||||
|
||||
|
||||
@@ -2676,7 +2676,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
10.5 Search algorithms revisited
|
||||
10.5 Search Algorithms Revisited
|
||||
|
||||
|
||||
|
||||
@@ -2825,7 +2825,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.1 Sorting algorithms
|
||||
11.1 Sorting Algorithms
|
||||
|
||||
|
||||
|
||||
@@ -2853,7 +2853,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.2 Selection sort
|
||||
11.2 Selection Sort
|
||||
|
||||
|
||||
|
||||
@@ -2881,7 +2881,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.3 Bubble sort
|
||||
11.3 Bubble Sort
|
||||
|
||||
|
||||
|
||||
@@ -2909,7 +2909,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.4 Insertion sort
|
||||
11.4 Insertion Sort
|
||||
|
||||
|
||||
|
||||
@@ -2937,7 +2937,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.5 Quick sort
|
||||
11.5 Quick Sort
|
||||
|
||||
|
||||
|
||||
@@ -2965,7 +2965,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.6 Merge sort
|
||||
11.6 Merge Sort
|
||||
|
||||
|
||||
|
||||
@@ -2993,7 +2993,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.7 Heap sort
|
||||
11.7 Heap Sort
|
||||
|
||||
|
||||
|
||||
@@ -3021,7 +3021,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.8 Bucket sort
|
||||
11.8 Bucket Sort
|
||||
|
||||
|
||||
|
||||
@@ -3049,7 +3049,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.9 Counting sort
|
||||
11.9 Counting Sort
|
||||
|
||||
|
||||
|
||||
@@ -3077,7 +3077,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
11.10 Radix sort
|
||||
11.10 Radix Sort
|
||||
|
||||
|
||||
|
||||
@@ -3170,7 +3170,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 12. Divide and conquer
|
||||
Chapter 12. Divide and Conquer
|
||||
|
||||
|
||||
|
||||
@@ -3192,7 +3192,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 12. Divide and conquer
|
||||
Chapter 12. Divide and Conquer
|
||||
|
||||
|
||||
</label>
|
||||
@@ -3214,7 +3214,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.1 Divide and conquer algorithms
|
||||
12.1 Divide and Conquer Algorithms
|
||||
|
||||
|
||||
|
||||
@@ -3242,7 +3242,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.2 Divide and conquer search strategy
|
||||
12.2 Divide and Conquer Search Strategy
|
||||
|
||||
|
||||
|
||||
@@ -3270,7 +3270,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.3 Building binary tree problem
|
||||
12.3 Building a Binary Tree Problem
|
||||
|
||||
|
||||
|
||||
@@ -3298,7 +3298,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
12.4 Tower of Hanoi Problem
|
||||
12.4 Hanoi Tower Problem
|
||||
|
||||
|
||||
|
||||
@@ -3435,7 +3435,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.1 Backtracking algorithms
|
||||
13.1 Backtracking Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -3463,7 +3463,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.2 Permutation problem
|
||||
13.2 Permutations Problem
|
||||
|
||||
|
||||
|
||||
@@ -3491,7 +3491,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.3 Subset sum problem
|
||||
13.3 Subset-Sum Problem
|
||||
|
||||
|
||||
|
||||
@@ -3519,7 +3519,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
13.4 n queens problem
|
||||
13.4 N-Queens Problem
|
||||
|
||||
|
||||
|
||||
@@ -3616,7 +3616,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
Chapter 14. Dynamic programming
|
||||
Chapter 14. Dynamic Programming
|
||||
|
||||
|
||||
|
||||
@@ -3638,7 +3638,7 @@
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
||||
|
||||
Chapter 14. Dynamic programming
|
||||
Chapter 14. Dynamic Programming
|
||||
|
||||
|
||||
</label>
|
||||
@@ -3660,7 +3660,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.1 Introduction to dynamic programming
|
||||
14.1 Introduction to Dynamic Programming
|
||||
|
||||
|
||||
|
||||
@@ -3688,7 +3688,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.2 Characteristics of DP problems
|
||||
14.2 Characteristics of Dynamic Programming Problems
|
||||
|
||||
|
||||
|
||||
@@ -3716,7 +3716,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.3 DP problem-solving approach¶
|
||||
14.3 Dynamic Programming Problem-Solving Approach
|
||||
|
||||
|
||||
|
||||
@@ -3744,7 +3744,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.4 0-1 Knapsack problem
|
||||
14.4 0-1 Knapsack Problem
|
||||
|
||||
|
||||
|
||||
@@ -3772,7 +3772,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.5 Unbounded knapsack problem
|
||||
14.5 Unbounded Knapsack Problem
|
||||
|
||||
|
||||
|
||||
@@ -3800,7 +3800,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
14.6 Edit distance problem
|
||||
14.6 Edit Distance Problem
|
||||
|
||||
|
||||
|
||||
@@ -3937,7 +3937,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.1 Greedy algorithms
|
||||
15.1 Greedy Algorithm
|
||||
|
||||
|
||||
|
||||
@@ -3965,7 +3965,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.2 Fractional knapsack problem
|
||||
15.2 Fractional Knapsack Problem
|
||||
|
||||
|
||||
|
||||
@@ -3993,7 +3993,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.3 Maximum capacity problem
|
||||
15.3 Maximum Capacity Problem
|
||||
|
||||
|
||||
|
||||
@@ -4021,7 +4021,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
15.4 Maximum product cutting problem
|
||||
15.4 Maximum Product Cutting Problem
|
||||
|
||||
|
||||
|
||||
@@ -4154,7 +4154,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
16.1 Installation
|
||||
16.1 Programming Environment Installation
|
||||
|
||||
|
||||
|
||||
@@ -4182,7 +4182,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
16.2 Contributing
|
||||
16.2 Contributing Together
|
||||
|
||||
|
||||
|
||||
@@ -4210,7 +4210,7 @@
|
||||
<span class="md-ellipsis">
|
||||
|
||||
|
||||
16.3 Terminology
|
||||
16.3 Terminology Table
|
||||
|
||||
|
||||
|
||||
@@ -4327,7 +4327,7 @@
|
||||
<a href="#311-logical-structure-linear-and-non-linear" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
3.1.1 Logical structure: linear and non-linear
|
||||
3.1.1 Logical Structure: Linear and Non-Linear
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -4338,7 +4338,7 @@
|
||||
<a href="#312-physical-structure-contiguous-and-dispersed" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
3.1.2 Physical structure: contiguous and dispersed
|
||||
3.1.2 Physical Structure: Contiguous and Dispersed
|
||||
|
||||
</span>
|
||||
</a>
|
||||
@@ -4382,47 +4382,47 @@
|
||||
|
||||
|
||||
<!-- Page content -->
|
||||
<h1 id="31-classification-of-data-structures">3.1 Classification of data structures<a class="headerlink" href="#31-classification-of-data-structures" title="Permanent link">¶</a></h1>
|
||||
<p>Common data structures include arrays, linked lists, stacks, queues, hash tables, trees, heaps, and graphs. They can be classified into "logical structure" and "physical structure".</p>
|
||||
<h2 id="311-logical-structure-linear-and-non-linear">3.1.1 Logical structure: linear and non-linear<a class="headerlink" href="#311-logical-structure-linear-and-non-linear" title="Permanent link">¶</a></h2>
|
||||
<p><strong>The logical structures reveal the logical relationships between data elements</strong>. In arrays and linked lists, data are arranged in a specific sequence, demonstrating the linear relationship between data; while in trees, data are arranged hierarchically from the top down, showing the derived relationship between "ancestors" and "descendants"; and graphs are composed of nodes and edges, reflecting the intricate network relationship.</p>
|
||||
<p>As shown in Figure 3-1, logical structures can be divided into two major categories: "linear" and "non-linear". Linear structures are more intuitive, indicating data is arranged linearly in logical relationships; non-linear structures, conversely, are arranged non-linearly.</p>
|
||||
<h1 id="31-classification-of-data-structures">3.1 Classification of Data Structures<a class="headerlink" href="#31-classification-of-data-structures" title="Permanent link">¶</a></h1>
|
||||
<p>Common data structures include arrays, linked lists, stacks, queues, hash tables, trees, heaps, and graphs. They can be classified from two dimensions: "logical structure" and "physical structure".</p>
|
||||
<h2 id="311-logical-structure-linear-and-non-linear">3.1.1 Logical Structure: Linear and Non-Linear<a class="headerlink" href="#311-logical-structure-linear-and-non-linear" title="Permanent link">¶</a></h2>
|
||||
<p><strong>Logical structure reveals the logical relationships between data elements</strong>. In arrays and linked lists, data is arranged in a certain order, embodying the linear relationship between data; while in trees, data is arranged hierarchically from top to bottom, showing the derived relationship between "ancestors" and "descendants"; graphs are composed of nodes and edges, reflecting complex network relationships.</p>
|
||||
<p>As shown in Figure 3-1, logical structures can be divided into two major categories: "linear" and "non-linear". Linear structures are more intuitive, indicating that data is linearly arranged in logical relationships; non-linear structures are the opposite, arranged non-linearly.</p>
|
||||
<ul>
|
||||
<li><strong>Linear data structures</strong>: Arrays, Linked Lists, Stacks, Queues, Hash Tables, where elements have a one-to-one sequential relationship.</li>
|
||||
<li><strong>Non-linear data structures</strong>: Trees, Heaps, Graphs, Hash Tables.</li>
|
||||
<li><strong>Linear data structures</strong>: Arrays, linked lists, stacks, queues, hash tables, where elements have a one-to-one sequential relationship.</li>
|
||||
<li><strong>Non-linear data structures</strong>: Trees, heaps, graphs, hash tables.</li>
|
||||
</ul>
|
||||
<p>Non-linear data structures can be further divided into tree structures and network structures.</p>
|
||||
<ul>
|
||||
<li><strong>Tree structures</strong>: Trees, Heaps, Hash Tables, where elements have a one-to-many relationship.</li>
|
||||
<li><strong>Network structures</strong>: Graphs, where elements have a many-to-many relationships.</li>
|
||||
<li><strong>Tree structures</strong>: Trees, heaps, hash tables, where elements have a one-to-many relationship.</li>
|
||||
<li><strong>Network structures</strong>: Graphs, where elements have a many-to-many relationship.</li>
|
||||
</ul>
|
||||
<p><a class="glightbox" href="../classification_of_data_structure.assets/classification_logic_structure.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Linear and non-linear data structures" class="animation-figure" src="../classification_of_data_structure.assets/classification_logic_structure.png" /></a></p>
|
||||
<p align="center"> Figure 3-1 Linear and non-linear data structures </p>
|
||||
|
||||
<h2 id="312-physical-structure-contiguous-and-dispersed">3.1.2 Physical structure: contiguous and dispersed<a class="headerlink" href="#312-physical-structure-contiguous-and-dispersed" title="Permanent link">¶</a></h2>
|
||||
<p><strong>During the execution of an algorithm, the data being processed is stored in memory</strong>. Figure 3-2 shows a computer memory stick where each black square is a physical memory space. We can think of memory as a vast Excel spreadsheet, with each cell capable of storing a certain amount of data.</p>
|
||||
<p><strong>The system accesses the data at the target location by means of a memory address</strong>. As shown in Figure 3-2, the computer assigns a unique identifier to each cell in the table according to specific rules, ensuring that each memory space has a unique memory address. With these addresses, the program can access the data stored in memory.</p>
|
||||
<p><a class="glightbox" href="../classification_of_data_structure.assets/computer_memory_location.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Memory stick, memory spaces, memory addresses" class="animation-figure" src="../classification_of_data_structure.assets/computer_memory_location.png" /></a></p>
|
||||
<p align="center"> Figure 3-2 Memory stick, memory spaces, memory addresses </p>
|
||||
<h2 id="312-physical-structure-contiguous-and-dispersed">3.1.2 Physical Structure: Contiguous and Dispersed<a class="headerlink" href="#312-physical-structure-contiguous-and-dispersed" title="Permanent link">¶</a></h2>
|
||||
<p><strong>When an algorithm program runs, the data being processed is mainly stored in memory</strong>. Figure 3-2 shows a computer memory stick, where each black square contains a memory space. We can imagine memory as a huge Excel spreadsheet, where each cell can store a certain amount of data.</p>
|
||||
<p><strong>The system accesses data at the target location through memory addresses</strong>. As shown in Figure 3-2, the computer assigns a number to each cell in the spreadsheet according to specific rules, ensuring that each memory space has a unique memory address. With these addresses, the program can access data in memory.</p>
|
||||
<p><a class="glightbox" href="../classification_of_data_structure.assets/computer_memory_location.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Memory stick, memory space, memory address" class="animation-figure" src="../classification_of_data_structure.assets/computer_memory_location.png" /></a></p>
|
||||
<p align="center"> Figure 3-2 Memory stick, memory space, memory address </p>
|
||||
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Tip</p>
|
||||
<p>It's worth noting that comparing memory to an Excel spreadsheet is a simplified analogy. The actual working mechanism of memory is more complex, involving concepts like address space, memory management, cache mechanisms, virtual memory, and physical memory.</p>
|
||||
<p>It is worth noting that comparing memory to an Excel spreadsheet is a simplified analogy. The actual working mechanism of memory is quite complex, involving concepts such as address space, memory management, cache mechanisms, virtual memory, and physical memory.</p>
|
||||
</div>
|
||||
<p>Memory is a shared resource for all programs. When a block of memory is occupied by one program, it cannot be simultaneously used by other programs. <strong>Therefore, memory resources are an important consideration in the design of data structures and algorithms</strong>. For instance, the algorithm's peak memory usage should not exceed the remaining free memory of the system; if there is a lack of contiguous memory blocks, then the data structure chosen must be able to be stored in non-contiguous memory blocks.</p>
|
||||
<p>As illustrated in Figure 3-3, <strong>the physical structure reflects the way data is stored in computer memory</strong> and it can be divided into contiguous space storage (arrays) and non-contiguous space storage (linked lists). The two types of physical structures exhibit complementary characteristics in terms of time efficiency and space efficiency.</p>
|
||||
<p>Memory is a shared resource for all programs. When a block of memory is occupied by a program, it usually cannot be used by other programs at the same time. <strong>Therefore, in the design of data structures and algorithms, memory resources are an important consideration</strong>. For example, the peak memory occupied by an algorithm should not exceed the remaining free memory of the system; if there is a lack of contiguous large memory blocks, then the data structure chosen must be able to be stored in dispersed memory spaces.</p>
|
||||
<p>As shown in Figure 3-3, <strong>physical structure reflects the way data is stored in computer memory</strong>, and can be divided into contiguous space storage (arrays) and dispersed space storage (linked lists). The two physical structures exhibit complementary characteristics in terms of time efficiency and space efficiency.</p>
|
||||
<p><a class="glightbox" href="../classification_of_data_structure.assets/classification_phisical_structure.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Contiguous space storage and dispersed space storage" class="animation-figure" src="../classification_of_data_structure.assets/classification_phisical_structure.png" /></a></p>
|
||||
<p align="center"> Figure 3-3 Contiguous space storage and dispersed space storage </p>
|
||||
|
||||
<p><strong>It is worth noting that all data structures are implemented based on arrays, linked lists, or a combination of both</strong>. For example, stacks and queues can be implemented using either arrays or linked lists; while implementations of hash tables may involve both arrays and linked lists.</p>
|
||||
<p>It is worth noting that <strong>all data structures are implemented based on arrays, linked lists, or a combination of both</strong>. For example, stacks and queues can be implemented using either arrays or linked lists; while the implementation of hash tables may include both arrays and linked lists.</p>
|
||||
<ul>
|
||||
<li><strong>Array-based implementations</strong>: Stacks, Queues, Hash Tables, Trees, Heaps, Graphs, Matrices, Tensors (arrays with dimensions <span class="arithmatex">\(\geq 3\)</span>).</li>
|
||||
<li><strong>Linked-list-based implementations</strong>: Stacks, Queues, Hash Tables, Trees, Heaps, Graphs, etc.</li>
|
||||
<li><strong>Can be implemented based on arrays</strong>: Stacks, queues, hash tables, trees, heaps, graphs, matrices, tensors (arrays with dimensions <span class="arithmatex">\(\geq 3\)</span>), etc.</li>
|
||||
<li><strong>Can be implemented based on linked lists</strong>: Stacks, queues, hash tables, trees, heaps, graphs, etc.</li>
|
||||
</ul>
|
||||
<p>Data structures implemented based on arrays are also called “Static Data Structures,” meaning their length cannot be changed after initialization. Conversely, those based on linked lists are called “Dynamic Data Structures,” which can still adjust their size during program execution.</p>
|
||||
<p>After initialization, linked lists can still adjust their length during program execution, so they are also called "dynamic data structures". After initialization, the length of arrays cannot be changed, so they are also called "static data structures". It is worth noting that arrays can achieve length changes by reallocating memory, thus possessing a certain degree of "dynamism".</p>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Tip</p>
|
||||
<p>If you find it challenging to comprehend the physical structure, it is recommended that you read the next chapter, "Arrays and Linked Lists," and revisit this section later.</p>
|
||||
<p>If you find it difficult to understand physical structure, it is recommended to read the next chapter first, and then review this section.</p>
|
||||
</div>
|
||||
|
||||
<!-- Source file information -->
|
||||
@@ -4446,7 +4446,7 @@ aria-label="Footer"
|
||||
<a
|
||||
href="../"
|
||||
class="md-footer__link md-footer__link--prev"
|
||||
aria-label="Previous: Chapter 3. &nbsp; Data structures"
|
||||
aria-label="Previous: Chapter 3. &nbsp; Data Structures"
|
||||
rel="prev"
|
||||
>
|
||||
<div class="md-footer__button md-icon">
|
||||
@@ -4458,7 +4458,7 @@ aria-label="Footer"
|
||||
Previous
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
Chapter 3. Data structures
|
||||
Chapter 3. Data Structures
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@@ -4470,7 +4470,7 @@ aria-label="Footer"
|
||||
<a
|
||||
href="../basic_data_types/"
|
||||
class="md-footer__link md-footer__link--next"
|
||||
aria-label="Next: 3.2 Basic data types"
|
||||
aria-label="Next: 3.2 Basic Data Types"
|
||||
rel="next"
|
||||
>
|
||||
<div class="md-footer__title">
|
||||
@@ -4478,7 +4478,7 @@ aria-label="Footer"
|
||||
Next
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
3.2 Basic data types
|
||||
3.2 Basic Data Types
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-footer__button md-icon">
|
||||
@@ -4571,7 +4571,7 @@ aria-label="Footer"
|
||||
<nav class="md-footer__inner md-grid" aria-label="Footer" >
|
||||
|
||||
|
||||
<a href="../" class="md-footer__link md-footer__link--prev" aria-label="Previous: Chapter 3. &nbsp; Data structures">
|
||||
<a href="../" class="md-footer__link md-footer__link--prev" aria-label="Previous: Chapter 3. &nbsp; Data Structures">
|
||||
<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>
|
||||
@@ -4581,20 +4581,20 @@ aria-label="Footer"
|
||||
Previous
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
Chapter 3. Data structures
|
||||
Chapter 3. Data Structures
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<a href="../basic_data_types/" class="md-footer__link md-footer__link--next" aria-label="Next: 3.2 Basic data types">
|
||||
<a href="../basic_data_types/" class="md-footer__link md-footer__link--next" aria-label="Next: 3.2 Basic Data Types">
|
||||
<div class="md-footer__title">
|
||||
<span class="md-footer__direction">
|
||||
Next
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
3.2 Basic data types
|
||||
3.2 Basic Data Types
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-footer__button md-icon">
|
||||
|
||||
Reference in New Issue
Block a user