Rename the naming of the coding files

in backtracking algorithm.
Add the typedef to docs.
This commit is contained in:
krahets 2023-04-22 01:38:53 +08:00
parent 9eeefff447
commit bad759b4f8
17 changed files with 98 additions and 98 deletions

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_nodes.cpp
* File: preorder_traversal_i_compact.cpp
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -8,7 +8,7 @@
vector<TreeNode *> res;
/* 前序遍历 */
/* 前序遍历:例题一 */
static void preOrder(TreeNode *root) {
if (root == nullptr) {
return;

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_paths.cpp
* File: preorder_traversal_ii_compact.cpp
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -9,7 +9,7 @@
vector<TreeNode *> path;
vector<vector<TreeNode *>> res;
/* 前序遍历 */
/* 前序遍历:例题二 */
static void preOrder(TreeNode *root) {
if (root == nullptr) {
return;

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_constrained_paths.cpp
* File: preorder_traversal_iii_compact.cpp
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -9,7 +9,7 @@
vector<TreeNode *> path;
vector<vector<TreeNode *>> res;
/* 前序遍历 */
/* 前序遍历:例题三 */
static void preOrder(TreeNode *root) {
// 剪枝
if (root == nullptr || root->val == 3) {

View file

@ -1,5 +1,5 @@
/**
* File: backtrack_find_constrained_paths.cpp
* File: preorder_traversal_iii_template.cpp
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -31,7 +31,7 @@ void undoChoice(vector<TreeNode *> &state, TreeNode *choice) {
state.pop_back();
}
/* 回溯算法 */
/* 回溯算法:例题三 */
void backtrack(vector<TreeNode *> &state, vector<TreeNode *> &choices, vector<vector<TreeNode *>> &res) {
// 检查是否为解
if (isSolution(state)) {

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_nodes.cs
* File: preorder_traversal_i_compact.cs
* Created Time: 2023-04-17
* Author: hpstory (hpstory1024@163.com)
*/
@ -10,11 +10,11 @@ using System.IO;
namespace hello_algo.chapter_backtracking;
public class preorder_find_nodes
public class preorder_traversal_i_compact
{
static List<TreeNode> res;
/* 前序遍历 */
/* 前序遍历:例题一 */
static void preOrder(TreeNode root)
{
if (root == null)

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_paths.cs
* File: preorder_traversal_ii_compact.cs
* Created Time: 2023-04-17
* Author: hpstory (hpstory1024@163.com)
*/
@ -9,12 +9,12 @@ using NUnit.Framework;
namespace hello_algo.chapter_backtracking;
public class preorder_find_paths
public class preorder_traversal_ii_compact
{
static List<TreeNode> path;
static List<List<TreeNode>> res;
/* 前序遍历 */
/* 前序遍历:例题二 */
static void preOrder(TreeNode root)
{
if (root == null)

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_constrained_paths.cs
* File: preorder_traversal_iii_compact.cs
* Created Time: 2023-04-17
* Author: hpstory (hpstory1024@163.com)
*/
@ -9,12 +9,12 @@ using NUnit.Framework;
namespace hello_algo.chapter_backtracking;
public class preorder_find_constrained_paths
public class preorder_traversal_iii_compact
{
static List<TreeNode> path;
static List<List<TreeNode>> res;
/* 前序遍历 */
/* 前序遍历:例题三 */
static void preOrder(TreeNode root)
{
// 剪枝

View file

@ -1,5 +1,5 @@
/**
* File: backtrack_find_constrained_paths.cs
* File: preorder_traversal_iii_template.cs
* Created Time: 2023-04-17
* Author: hpstory (hpstory1024@163.com)
*/
@ -9,7 +9,7 @@ using NUnit.Framework;
namespace hello_algo.chapter_backtracking;
public class backtrack_find_constrained_paths
public class preorder_traversal_iii_template
{
/* 判断当前状态是否为解 */
static bool isSolution(List<TreeNode> state)
@ -41,7 +41,7 @@ public class backtrack_find_constrained_paths
state.RemoveAt(state.Count - 1);
}
/* 回溯算法 */
/* 回溯算法:例题三 */
static void backtrack(List<TreeNode> state, List<TreeNode> choices, List<List<TreeNode>> res)
{
// 检查是否为解

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_nodes.java
* File: preorder_traversal_i_compact.java
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -9,10 +9,10 @@ package chapter_backtracking;
import include.*;
import java.util.*;
public class preorder_find_nodes {
public class preorder_traversal_i_compact {
static List<TreeNode> res;
/* 前序遍历 */
/* 前序遍历:例题一 */
static void preOrder(TreeNode root) {
if (root == null) {
return;

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_paths.java
* File: preorder_traversal_ii_compact.java
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -9,11 +9,11 @@ package chapter_backtracking;
import include.*;
import java.util.*;
public class preorder_find_paths {
public class preorder_traversal_ii_compact {
static List<TreeNode> path;
static List<List<TreeNode>> res;
/* 前序遍历 */
/* 前序遍历:例题二 */
static void preOrder(TreeNode root) {
if (root == null) {
return;

View file

@ -1,5 +1,5 @@
/**
* File: preorder_find_constrained_paths.java
* File: preorder_traversal_iii_compact.java
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -9,11 +9,11 @@ package chapter_backtracking;
import include.*;
import java.util.*;
public class preorder_find_constrained_paths {
public class preorder_traversal_iii_compact {
static List<TreeNode> path;
static List<List<TreeNode>> res;
/* 前序遍历 */
/* 前序遍历:例题三 */
static void preOrder(TreeNode root) {
// 剪枝
if (root == null || root.val == 3) {

View file

@ -1,5 +1,5 @@
/**
* File: backtrack_find_constrained_paths.java
* File: preorder_traversal_iii_template.java
* Created Time: 2023-04-16
* Author: Krahets (krahets@163.com)
*/
@ -9,7 +9,7 @@ package chapter_backtracking;
import include.*;
import java.util.*;
public class backtrack_find_constrained_paths {
public class preorder_traversal_iii_template {
/* 判断当前状态是否为解 */
static boolean isSolution(List<TreeNode> state) {
return !state.isEmpty() && state.get(state.size() - 1).val == 7;
@ -35,7 +35,7 @@ public class backtrack_find_constrained_paths {
state.remove(state.size() - 1);
}
/* 回溯算法 */
/* 回溯算法:例题三 */
static void backtrack(List<TreeNode> state, List<TreeNode> choices, List<List<TreeNode>> res) {
// 检查是否为解
if (isSolution(state)) {

View file

@ -1,5 +1,5 @@
"""
File: preorder_find_nodes.py
File: find_nodes-preorder.py
Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
@ -11,7 +11,7 @@ from modules import *
def pre_order(root: TreeNode) -> None:
"""前序遍历"""
"""前序遍历:例题一"""
if root is None:
return
if root.val == 7:

View file

@ -1,5 +1,5 @@
"""
File: preorder_find_paths.py
File: find_paths-preorder.py
Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
@ -11,7 +11,7 @@ from modules import *
def pre_order(root: TreeNode) -> None:
"""前序遍历"""
"""前序遍历:例题二"""
if root is None:
return
# 尝试

View file

@ -1,5 +1,5 @@
"""
File: preorder_find_constrained_path.py
File: find_constrained_paths_template.py
Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
@ -11,7 +11,7 @@ from modules import *
def pre_order(root: TreeNode) -> None:
"""前序遍历"""
"""前序遍历:例题三"""
# 剪枝
if root is None or root.val == 3:
return

View file

@ -1,5 +1,5 @@
"""
File: backtrack_find_constrained_path.py
File: find_constrained_paths_template.py
Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
@ -36,7 +36,7 @@ def undo_choice(state: list[TreeNode], choice: TreeNode):
def backtrack(state: list[TreeNode], choices: list[TreeNode], res: list[list[TreeNode]]):
"""回溯算法"""
"""回溯算法:例题三"""
# 检查是否为解
if is_solution(state):
# 记录解

View file

@ -10,61 +10,61 @@
=== "Java"
```java title="preorder_find_nodes.java"
[class]{preorder_find_nodes}-[func]{preOrder}
```java title="preorder_traversal_i_compact.java"
[class]{preorder_traversal_i_compact}-[func]{preOrder}
```
=== "C++"
```cpp title="preorder_find_nodes.cpp"
```cpp title="preorder_traversal_i_compact.cpp"
[class]{}-[func]{preOrder}
```
=== "Python"
```python title="preorder_find_nodes.py"
```python title="preorder_traversal_i_compact.py"
[class]{}-[func]{pre_order}
```
=== "Go"
```go title="preorder_find_nodes.go"
```go title="preorder_traversal_i_compact.go"
[class]{}-[func]{preOrder}
```
=== "JavaScript"
```javascript title="preorder_find_nodes.js"
```javascript title="preorder_traversal_i_compact.js"
[class]{}-[func]{preOrder}
```
=== "TypeScript"
```typescript title="preorder_find_nodes.ts"
```typescript title="preorder_traversal_i_compact.ts"
[class]{}-[func]{preOrder}
```
=== "C"
```c title="preorder_find_nodes.c"
```c title="preorder_traversal_i_compact.c"
[class]{}-[func]{preOrder}
```
=== "C#"
```csharp title="preorder_find_nodes.cs"
[class]{preorder_find_nodes}-[func]{preOrder}
```csharp title="preorder_traversal_i_compact.cs"
[class]{preorder_traversal_i_compact}-[func]{preOrder}
```
=== "Swift"
```swift title="preorder_find_nodes.swift"
```swift title="preorder_traversal_i_compact.swift"
[class]{}-[func]{preOrder}
```
=== "Zig"
```zig title="preorder_find_nodes.zig"
```zig title="preorder_traversal_i_compact.zig"
[class]{}-[func]{preOrder}
```
@ -84,61 +84,61 @@
=== "Java"
```java title="preorder_find_paths.java"
[class]{preorder_find_paths}-[func]{preOrder}
```java title="preorder_traversal_ii_compact.java"
[class]{preorder_traversal_ii_compact}-[func]{preOrder}
```
=== "C++"
```cpp title="preorder_find_paths.cpp"
```cpp title="preorder_traversal_ii_compact.cpp"
[class]{}-[func]{preOrder}
```
=== "Python"
```python title="preorder_find_paths.py"
```python title="preorder_traversal_ii_compact.py"
[class]{}-[func]{pre_order}
```
=== "Go"
```go title="preorder_find_paths.go"
```go title="preorder_traversal_ii_compact.go"
[class]{}-[func]{preOrder}
```
=== "JavaScript"
```javascript title="preorder_find_paths.js"
```javascript title="preorder_traversal_ii_compact.js"
[class]{}-[func]{preOrder}
```
=== "TypeScript"
```typescript title="preorder_find_paths.ts"
```typescript title="preorder_traversal_ii_compact.ts"
[class]{}-[func]{preOrder}
```
=== "C"
```c title="preorder_find_paths.c"
```c title="preorder_traversal_ii_compact.c"
[class]{}-[func]{preOrder}
```
=== "C#"
```csharp title="preorder_find_paths.cs"
[class]{preorder_find_paths}-[func]{preOrder}
```csharp title="preorder_traversal_ii_compact.cs"
[class]{preorder_traversal_ii_compact}-[func]{preOrder}
```
=== "Swift"
```swift title="preorder_find_paths.swift"
```swift title="preorder_traversal_ii_compact.swift"
[class]{}-[func]{preOrder}
```
=== "Zig"
```zig title="preorder_find_paths.zig"
```zig title="preorder_traversal_ii_compact.zig"
[class]{}-[func]{preOrder}
```
@ -187,61 +187,61 @@
=== "Java"
```java title="preorder_find_constrained_paths.java"
[class]{preorder_find_constrained_paths}-[func]{preOrder}
```java title="preorder_traversal_iii_compact.java"
[class]{preorder_traversal_iii_compact}-[func]{preOrder}
```
=== "C++"
```cpp title="preorder_find_constrained_paths.cpp"
```cpp title="preorder_traversal_iii_compact.cpp"
[class]{}-[func]{preOrder}
```
=== "Python"
```python title="preorder_find_constrained_paths.py"
```python title="preorder_traversal_iii_compact.py"
[class]{}-[func]{pre_order}
```
=== "Go"
```go title="preorder_find_constrained_paths.go"
```go title="preorder_traversal_iii_compact.go"
[class]{}-[func]{preOrder}
```
=== "JavaScript"
```javascript title="preorder_find_constrained_paths.js"
```javascript title="preorder_traversal_iii_compact.js"
[class]{}-[func]{preOrder}
```
=== "TypeScript"
```typescript title="preorder_find_constrained_paths.ts"
```typescript title="preorder_traversal_iii_compact.ts"
[class]{}-[func]{preOrder}
```
=== "C"
```c title="preorder_find_constrained_paths.c"
```c title="preorder_traversal_iii_compact.c"
[class]{}-[func]{preOrder}
```
=== "C#"
```csharp title="preorder_find_constrained_paths.cs"
[class]{preorder_find_constrained_paths}-[func]{preOrder}
```csharp title="preorder_traversal_iii_compact.cs"
[class]{preorder_traversal_iii_compact}-[func]{preOrder}
```
=== "Swift"
```swift title="preorder_find_constrained_paths.swift"
```swift title="preorder_traversal_iii_compact.swift"
[class]{}-[func]{preOrder}
```
=== "Zig"
```zig title="preorder_find_constrained_paths.zig"
```zig title="preorder_traversal_iii_compact.zig"
[class]{}-[func]{preOrder}
```
@ -295,23 +295,23 @@ def backtrack(state, choices, res):
=== "Java"
```java title="backtrack_find_constrained_paths.java"
[class]{backtrack_find_constrained_paths}-[func]{isSolution}
```java title="preorder_traversal_iii_template.java"
[class]{preorder_traversal_iii_template}-[func]{isSolution}
[class]{backtrack_find_constrained_paths}-[func]{recordSolution}
[class]{preorder_traversal_iii_template}-[func]{recordSolution}
[class]{backtrack_find_constrained_paths}-[func]{isValid}
[class]{preorder_traversal_iii_template}-[func]{isValid}
[class]{backtrack_find_constrained_paths}-[func]{makeChoice}
[class]{preorder_traversal_iii_template}-[func]{makeChoice}
[class]{backtrack_find_constrained_paths}-[func]{undoChoice}
[class]{preorder_traversal_iii_template}-[func]{undoChoice}
[class]{backtrack_find_constrained_paths}-[func]{backtrack}
[class]{preorder_traversal_iii_template}-[func]{backtrack}
```
=== "C++"
```cpp title="backtrack_find_constrained_paths.cpp"
```cpp title="preorder_traversal_iii_template.cpp"
[class]{}-[func]{isSolution}
[class]{}-[func]{recordSolution}
@ -327,7 +327,7 @@ def backtrack(state, choices, res):
=== "Python"
```python title="backtrack_find_constrained_paths.py"
```python title="preorder_traversal_iii_template.py"
[class]{}-[func]{is_solution}
[class]{}-[func]{record_solution}
@ -343,7 +343,7 @@ def backtrack(state, choices, res):
=== "Go"
```go title="backtrack_find_constrained_paths.go"
```go title="preorder_traversal_iii_template.go"
[class]{}-[func]{isSolution}
[class]{}-[func]{recordSolution}
@ -359,7 +359,7 @@ def backtrack(state, choices, res):
=== "JavaScript"
```javascript title="backtrack_find_constrained_paths.js"
```javascript title="preorder_traversal_iii_template.js"
[class]{}-[func]{isSolution}
[class]{}-[func]{recordSolution}
@ -375,7 +375,7 @@ def backtrack(state, choices, res):
=== "TypeScript"
```typescript title="backtrack_find_constrained_paths.ts"
```typescript title="preorder_traversal_iii_template.ts"
[class]{}-[func]{isSolution}
[class]{}-[func]{recordSolution}
@ -391,7 +391,7 @@ def backtrack(state, choices, res):
=== "C"
```c title="backtrack_find_constrained_paths.c"
```c title="preorder_traversal_iii_template.c"
[class]{}-[func]{isSolution}
[class]{}-[func]{recordSolution}
@ -407,23 +407,23 @@ def backtrack(state, choices, res):
=== "C#"
```csharp title="backtrack_find_constrained_paths.cs"
[class]{backtrack_find_constrained_paths}-[func]{isSolution}
```csharp title="preorder_traversal_iii_template.cs"
[class]{preorder_traversal_iii_template}-[func]{isSolution}
[class]{backtrack_find_constrained_paths}-[func]{recordSolution}
[class]{preorder_traversal_iii_template}-[func]{recordSolution}
[class]{backtrack_find_constrained_paths}-[func]{isValid}
[class]{preorder_traversal_iii_template}-[func]{isValid}
[class]{backtrack_find_constrained_paths}-[func]{makeChoice}
[class]{preorder_traversal_iii_template}-[func]{makeChoice}
[class]{backtrack_find_constrained_paths}-[func]{undoChoice}
[class]{preorder_traversal_iii_template}-[func]{undoChoice}
[class]{backtrack_find_constrained_paths}-[func]{backtrack}
[class]{preorder_traversal_iii_template}-[func]{backtrack}
```
=== "Swift"
```swift title="backtrack_find_constrained_paths.swift"
```swift title="preorder_traversal_iii_template.swift"
[class]{}-[func]{isSolution}
[class]{}-[func]{recordSolution}
@ -439,7 +439,7 @@ def backtrack(state, choices, res):
=== "Zig"
```zig title="backtrack_find_constrained_paths.zig"
```zig title="preorder_traversal_iii_template.zig"
[class]{}-[func]{isSolution}
[class]{}-[func]{recordSolution}