hello-algo/en/docs/chapter_preface/suggestions.md

256 lines
9.2 KiB
Markdown
Raw Normal View History

2023-12-22 00:01:05 +08:00
---
comments: true
---
2023-12-27 00:48:00 +08:00
# 0.2   How to Read
2023-12-22 00:01:05 +08:00
!!! tip
For the best reading experience, it is recommended that you read through this section.
2024-01-07 23:42:54 +08:00
## 0.2.1   Writing Conventions
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
- Chapters marked with '*' after the title are optional and contain relatively challenging content. If you are short on time, it is advisable to skip them.
- Key technical terms and their English equivalents are enclosed in **Bold** + *italics* brackets, for example, ***array***. It's advisable to familiarize yourself with these for better comprehension of technical texts.
- Proprietary terms and words with specific meanings are indicated with “quotation marks” to avoid ambiguity.
- **Bolded text** indicates key content or summary statements, which deserve special attention.
- When it comes to terms that are inconsistent between programming languages, this book follows Python, for example using $\text{None}$ to mean "null".
- This book partially ignores the comment conventions for programming languages in exchange for a more compact layout of the content. The comments primarily consist of three types: title comments, content comments, and multi-line comments.
2023-12-22 00:01:05 +08:00
=== "Python"
```python title=""
2024-01-07 23:42:54 +08:00
"""Header comments for labeling functions, classes, test samples, etc""""
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
# Comments for explaining details
2023-12-22 00:01:05 +08:00
"""
2024-01-07 23:42:54 +08:00
Multiline
comments
2023-12-22 00:01:05 +08:00
"""
```
=== "C++"
```cpp title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "Java"
```java title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "C#"
```csharp title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "Go"
```go title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "Swift"
```swift title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "JS"
```javascript title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "TS"
```typescript title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "Dart"
```dart title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "Rust"
```rust title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
=== "C"
```c title=""
2024-01-07 23:42:54 +08:00
/* Header comments for labeling functions, classes, test samples, etc */
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
/**
2024-01-07 23:42:54 +08:00
* Multiline
* comments
2023-12-22 00:01:05 +08:00
*/
```
2024-03-25 22:43:12 +08:00
=== "Kotlin"
```kotlin title=""
/* Header comments for labeling functions, classes, test samples, etc */
// Comments for explaining details.
/**
* Multiline
* comments
*/
```
2023-12-22 00:01:05 +08:00
=== "Zig"
```zig title=""
2024-01-07 23:42:54 +08:00
// Header comments for labeling functions, classes, test samples, etc
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Comments for explaining details.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
// Multiline
// comments
2023-12-22 00:01:05 +08:00
```
2024-01-07 23:42:54 +08:00
## 0.2.2   Efficient Learning via Animated Illustrations
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
Compared with text, videos and pictures have a higher density of information and are more structured, making them easier to understand. In this book, **key and difficult concepts are mainly presented through animations and illustrations**, with text serving as explanations and supplements.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
When encountering content with animations or illustrations as shown in the Figure 0-2 , **prioritize understanding the figure, with text as supplementary**, integrating both for a comprehensive understanding.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
![Animated Illustration Example](../index.assets/animation.gif){ class="animation-figure" }
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
<p align="center"> Figure 0-2 &nbsp; Animated Illustration Example </p>
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
## 0.2.3 &nbsp; Deepen Understanding through Coding Practice
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
The source code of this book is hosted on the [GitHub Repository](https://github.com/krahets/hello-algo). As shown in the Figure 0-3 , **the source code comes with test examples and can be executed with just a single click**.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
If time permits, **it's recommended to type out the code yourself**. If pressed for time, at least read and run all the codes.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
Compared to just reading code, writing code often yields more learning. **Learning by doing is the real way to learn.**
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
![Running Code Example](../index.assets/running_code.gif){ class="animation-figure" }
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
<p align="center"> Figure 0-3 &nbsp; Running Code Example </p>
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
Setting up to run the code involves three main steps.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
**Step 1: Install a local programming environment**. Follow the [tutorial](https://www.hello-algo.com/chapter_appendix/installation/) in the appendix for installation, or skip this step if already installed.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
**Step 2: Clone or download the code repository**. Visit the [GitHub Repository](https://github.com/krahets/hello-algo).
If [Git](https://git-scm.com/downloads) is installed, use the following command to clone the repository:
2023-12-22 00:01:05 +08:00
```shell
git clone https://github.com/krahets/hello-algo.git
```
2024-01-07 23:42:54 +08:00
Alternatively, you can also click the "Download ZIP" button at the location shown in the Figure 0-4 to directly download the code as a compressed ZIP file. Then, you can simply extract it locally.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
![Cloning Repository and Downloading Code](suggestions.assets/download_code.png){ class="animation-figure" }
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
<p align="center"> Figure 0-4 &nbsp; Cloning Repository and Downloading Code </p>
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
**Step 3: Run the source code**. As shown in the Figure 0-5 , for the code block labeled with the file name at the top, we can find the corresponding source code file in the `codes` folder of the repository. These files can be executed with a single click, which will help you save unnecessary debugging time and allow you to focus on learning.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
![Code Block and Corresponding Source Code File](suggestions.assets/code_md_to_repo.png){ class="animation-figure" }
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
<p align="center"> Figure 0-5 &nbsp; Code Block and Corresponding Source Code File </p>
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
## 0.2.4 &nbsp; Learning Together in Discussion
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
While reading this book, please don't skip over the points that you didn't learn. **Feel free to post your questions in the comment section**. We will be happy to answer them and can usually respond within two days.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
As illustrated in the Figure 0-6 , each chapter features a comment section at the bottom. I encourage you to pay attention to these comments. They not only expose you to others' encountered problems, aiding in identifying knowledge gaps and sparking deeper contemplation, but also invite you to generously contribute by answering fellow readers' inquiries, sharing insights, and fostering mutual improvement.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
![Comment Section Example](../index.assets/comment.gif){ class="animation-figure" }
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
<p align="center"> Figure 0-6 &nbsp; Comment Section Example </p>
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
## 0.2.5 &nbsp; Algorithm Learning Path
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
Overall, the journey of mastering data structures and algorithms can be divided into three stages:
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
1. **Stage 1: Introduction to algorithms**. We need to familiarize ourselves with the characteristics and usage of various data structures and learn about the principles, processes, uses, and efficiency of different algorithms.
2. **Stage 2: Practicing algorithm problems**. It is recommended to start from popular problems, such as [Sword for Offer](https://leetcode.cn/studyplan/coding-interviews/) and [LeetCode Hot 100](https://leetcode.cn/studyplan/top-100- liked/), and accumulate at least 100 questions to familiarize yourself with mainstream algorithmic problems. Forgetfulness can be a challenge when you start practicing, but rest assured that this is normal. We can follow the "Ebbinghaus Forgetting Curve" to review the questions, and usually after 3~5 rounds of repetitions, we will be able to memorize them.
3. **Stage 3: Building the knowledge system**. In terms of learning, we can read algorithm column articles, solution frameworks, and algorithm textbooks to continuously enrich the knowledge system. In terms of practicing, we can try advanced strategies, such as categorizing by topic, multiple solutions for a single problem, and one solution for multiple problems, etc. Insights on these strategies can be found in various communities.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
As shown in the Figure 0-7 , this book mainly covers “Stage 1,” aiming to help you more efficiently embark on Stages 2 and 3.
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
![Algorithm Learning Path](suggestions.assets/learning_route.png){ class="animation-figure" }
2023-12-22 00:01:05 +08:00
2024-01-07 23:42:54 +08:00
<p align="center"> Figure 0-7 &nbsp; Algorithm Learning Path </p>