diff --git a/codes/c/CMakeLists.txt b/codes/c/CMakeLists.txt index 6128fceba..a1cc1d3c7 100644 --- a/codes/c/CMakeLists.txt +++ b/codes/c/CMakeLists.txt @@ -10,7 +10,6 @@ add_subdirectory(chapter_array_and_linkedlist) add_subdirectory(chapter_stack_and_queue) add_subdirectory(chapter_heap) add_subdirectory(chapter_hashing) -add_subdirectory(chapter_binary_search) add_subdirectory(chapter_tree) add_subdirectory(chapter_searching) add_subdirectory(chapter_sorting) \ No newline at end of file diff --git a/codes/c/chapter_binary_search/CMakeLists.txt b/codes/c/chapter_binary_search/CMakeLists.txt deleted file mode 100644 index 03d31e749..000000000 --- a/codes/c/chapter_binary_search/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_executable(binary_search binary_search.c) \ No newline at end of file diff --git a/codes/c/chapter_searching/CMakeLists.txt b/codes/c/chapter_searching/CMakeLists.txt index 104f7a1d5..6cdf80622 100644 --- a/codes/c/chapter_searching/CMakeLists.txt +++ b/codes/c/chapter_searching/CMakeLists.txt @@ -1 +1,2 @@ +add_executable(binary_search binary_search.c) add_executable(two_sum two_sum.c) \ No newline at end of file diff --git a/codes/c/chapter_binary_search/binary_search.c b/codes/c/chapter_searching/binary_search.c similarity index 100% rename from codes/c/chapter_binary_search/binary_search.c rename to codes/c/chapter_searching/binary_search.c diff --git a/codes/cpp/CMakeLists.txt b/codes/cpp/CMakeLists.txt index 164e94c81..9e3f5583a 100644 --- a/codes/cpp/CMakeLists.txt +++ b/codes/cpp/CMakeLists.txt @@ -8,7 +8,6 @@ include_directories(./include) add_subdirectory(chapter_computational_complexity) add_subdirectory(chapter_array_and_linkedlist) add_subdirectory(chapter_stack_and_queue) -add_subdirectory(chapter_binary_search) add_subdirectory(chapter_hashing) add_subdirectory(chapter_tree) add_subdirectory(chapter_heap) diff --git a/codes/cpp/chapter_binary_search/CMakeLists.txt b/codes/cpp/chapter_binary_search/CMakeLists.txt deleted file mode 100644 index 304737e1f..000000000 --- a/codes/cpp/chapter_binary_search/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_executable(binary_search binary_search.cpp) \ No newline at end of file diff --git a/codes/cpp/chapter_searching/CMakeLists.txt b/codes/cpp/chapter_searching/CMakeLists.txt index f003e3154..3b11b9fef 100644 --- a/codes/cpp/chapter_searching/CMakeLists.txt +++ b/codes/cpp/chapter_searching/CMakeLists.txt @@ -1,3 +1,5 @@ +add_executable(binary_search binary_search.cpp) +add_executable(binary_search binary_search_edge.cpp) add_executable(hashing_search hashing_search.cpp) add_executable(two_sum two_sum.cpp) add_executable(linear_search linear_search.cpp) \ No newline at end of file diff --git a/codes/cpp/chapter_binary_search/binary_search.cpp b/codes/cpp/chapter_searching/binary_search.cpp similarity index 100% rename from codes/cpp/chapter_binary_search/binary_search.cpp rename to codes/cpp/chapter_searching/binary_search.cpp diff --git a/codes/cpp/chapter_binary_search/binary_search_edge.cpp b/codes/cpp/chapter_searching/binary_search_edge.cpp similarity index 100% rename from codes/cpp/chapter_binary_search/binary_search_edge.cpp rename to codes/cpp/chapter_searching/binary_search_edge.cpp diff --git a/codes/csharp/chapter_binary_search/binary_search.cs b/codes/csharp/chapter_searching/binary_search.cs similarity index 98% rename from codes/csharp/chapter_binary_search/binary_search.cs rename to codes/csharp/chapter_searching/binary_search.cs index ec80f29d3..25e87e73f 100644 --- a/codes/csharp/chapter_binary_search/binary_search.cs +++ b/codes/csharp/chapter_searching/binary_search.cs @@ -4,7 +4,7 @@ * Author: haptear (haptear@hotmail.com) */ -namespace hello_algo.chapter_binary_search; +namespace hello_algo.chapter_searching; public class binary_search { /* 二分查找(双闭区间) */ diff --git a/codes/dart/chapter_binary_search/binary_search.dart b/codes/dart/chapter_searching/binary_search.dart similarity index 100% rename from codes/dart/chapter_binary_search/binary_search.dart rename to codes/dart/chapter_searching/binary_search.dart diff --git a/codes/go/chapter_binary_search/binary_search.go b/codes/go/chapter_searching/binary_search.go similarity index 97% rename from codes/go/chapter_binary_search/binary_search.go rename to codes/go/chapter_searching/binary_search.go index 1f792c417..5754ef698 100644 --- a/codes/go/chapter_binary_search/binary_search.go +++ b/codes/go/chapter_searching/binary_search.go @@ -2,7 +2,7 @@ // Created Time: 2022-12-05 // Author: Slone123c (274325721@qq.com) -package chapter_binary_search +package chapter_searching /* 二分查找(双闭区间) */ func binarySearch(nums []int, target int) int { diff --git a/codes/go/chapter_binary_search/binary_search_test.go b/codes/go/chapter_searching/binary_search_test.go similarity index 59% rename from codes/go/chapter_binary_search/binary_search_test.go rename to codes/go/chapter_searching/binary_search_test.go index 0cfedbdcd..2618f9ec0 100644 --- a/codes/go/chapter_binary_search/binary_search_test.go +++ b/codes/go/chapter_searching/binary_search_test.go @@ -2,7 +2,7 @@ // Created Time: 2022-12-05 // Author: Slone123c (274325721@qq.com) -package chapter_binary_search +package chapter_searching import ( "fmt" @@ -11,14 +11,14 @@ import ( func TestBinarySearch(t *testing.T) { var ( - target = 3 - nums = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + target = 6 + nums = []int{1, 3, 6, 8, 12, 15, 23, 67, 70, 92} expected = 2 ) // 在数组中执行二分查找 actual := binarySearch(nums, target) - fmt.Println("目标元素 3 的索引 =", actual) + fmt.Println("目标元素 6 的索引 =", actual) if actual != expected { - t.Errorf("目标元素 3 的索引 = %d, 应该为 %d", actual, expected) + t.Errorf("目标元素 6 的索引 = %d, 应该为 %d", actual, expected) } } diff --git a/codes/java/chapter_binary_search/binary_search.java b/codes/java/chapter_searching/binary_search.java similarity index 98% rename from codes/java/chapter_binary_search/binary_search.java rename to codes/java/chapter_searching/binary_search.java index b2115e445..ba15359c6 100644 --- a/codes/java/chapter_binary_search/binary_search.java +++ b/codes/java/chapter_searching/binary_search.java @@ -4,7 +4,7 @@ * Author: Krahets (krahets@163.com) */ -package chapter_binary_search; +package chapter_searching; public class binary_search { /* 二分查找(双闭区间) */ diff --git a/codes/java/chapter_binary_search/binary_search_edge.java b/codes/java/chapter_searching/binary_search_edge.java similarity index 98% rename from codes/java/chapter_binary_search/binary_search_edge.java rename to codes/java/chapter_searching/binary_search_edge.java index d63a8f658..847a41e85 100644 --- a/codes/java/chapter_binary_search/binary_search_edge.java +++ b/codes/java/chapter_searching/binary_search_edge.java @@ -4,7 +4,7 @@ * Author: Krahets (krahets@163.com) */ -package chapter_binary_search; +package chapter_searching; public class binary_search_edge { /* 二分查找最左一个元素 */ diff --git a/codes/javascript/chapter_binary_search/binary_search.js b/codes/javascript/chapter_searching/binary_search.js similarity index 100% rename from codes/javascript/chapter_binary_search/binary_search.js rename to codes/javascript/chapter_searching/binary_search.js diff --git a/codes/python/chapter_binary_search/binary_search.py b/codes/python/chapter_searching/binary_search.py similarity index 100% rename from codes/python/chapter_binary_search/binary_search.py rename to codes/python/chapter_searching/binary_search.py diff --git a/codes/python/chapter_binary_search/binary_search_edge.py b/codes/python/chapter_searching/binary_search_edge.py similarity index 100% rename from codes/python/chapter_binary_search/binary_search_edge.py rename to codes/python/chapter_searching/binary_search_edge.py diff --git a/codes/rust/chapter_binary_search/binary_search.rs b/codes/rust/chapter_searching/binary_search.rs similarity index 100% rename from codes/rust/chapter_binary_search/binary_search.rs rename to codes/rust/chapter_searching/binary_search.rs diff --git a/codes/swift/Package.swift b/codes/swift/Package.swift index 8d2716049..0ff7baec4 100644 --- a/codes/swift/Package.swift +++ b/codes/swift/Package.swift @@ -24,8 +24,6 @@ let package = Package( .executable(name: "deque", targets: ["deque"]), .executable(name: "linkedlist_deque", targets: ["linkedlist_deque"]), .executable(name: "array_deque", targets: ["array_deque"]), - // chapter_binary_search - .executable(name: "binary_search", targets: ["binary_search"]), // chapter_hashing .executable(name: "hash_map", targets: ["hash_map"]), .executable(name: "array_hash_map", targets: ["array_hash_map"]), @@ -43,6 +41,7 @@ let package = Package( .executable(name: "graph_bfs", targets: ["graph_bfs"]), .executable(name: "graph_dfs", targets: ["graph_dfs"]), // chapter_searching + .executable(name: "binary_search", targets: ["binary_search"]), .executable(name: "two_sum", targets: ["two_sum"]), .executable(name: "linear_search", targets: ["linear_search"]), .executable(name: "hashing_search", targets: ["hashing_search"]), @@ -86,8 +85,6 @@ let package = Package( .executableTarget(name: "deque", path: "chapter_stack_and_queue", sources: ["deque.swift"]), .executableTarget(name: "linkedlist_deque", path: "chapter_stack_and_queue", sources: ["linkedlist_deque.swift"]), .executableTarget(name: "array_deque", path: "chapter_stack_and_queue", sources: ["array_deque.swift"]), - // chapter_binary_search - .executableTarget(name: "binary_search", path: "chapter_binary_search", sources: ["binary_search.swift"]), // chapter_hashing .executableTarget(name: "hash_map", dependencies: ["utils"], path: "chapter_hashing", sources: ["hash_map.swift"]), .executableTarget(name: "array_hash_map", path: "chapter_hashing", sources: ["array_hash_map.swift"]), @@ -105,6 +102,7 @@ let package = Package( .executableTarget(name: "graph_bfs", dependencies: ["utils", "graph_adjacency_list_target"], path: "chapter_graph", sources: ["graph_bfs.swift"]), .executableTarget(name: "graph_dfs", dependencies: ["utils", "graph_adjacency_list_target"], path: "chapter_graph", sources: ["graph_dfs.swift"]), // chapter_searching + .executableTarget(name: "binary_search", path: "chapter_searching", sources: ["binary_search.swift"]), .executableTarget(name: "two_sum", path: "chapter_searching", sources: ["two_sum.swift"]), .executableTarget(name: "linear_search", dependencies: ["utils"], path: "chapter_searching", sources: ["linear_search.swift"]), .executableTarget(name: "hashing_search", dependencies: ["utils"], path: "chapter_searching", sources: ["hashing_search.swift"]), diff --git a/codes/swift/chapter_binary_search/binary_search.swift b/codes/swift/chapter_searching/binary_search.swift similarity index 100% rename from codes/swift/chapter_binary_search/binary_search.swift rename to codes/swift/chapter_searching/binary_search.swift diff --git a/codes/typescript/chapter_binary_search/binary_search.ts b/codes/typescript/chapter_searching/binary_search.ts similarity index 100% rename from codes/typescript/chapter_binary_search/binary_search.ts rename to codes/typescript/chapter_searching/binary_search.ts diff --git a/codes/zig/chapter_binary_search/binary_search.zig b/codes/zig/chapter_searching/binary_search.zig similarity index 100% rename from codes/zig/chapter_binary_search/binary_search.zig rename to codes/zig/chapter_searching/binary_search.zig diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_ranges.png b/docs/chapter_searching/binary_search.assets/binary_search_ranges.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_ranges.png rename to docs/chapter_searching/binary_search.assets/binary_search_ranges.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step0.png b/docs/chapter_searching/binary_search.assets/binary_search_step0.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step0.png rename to docs/chapter_searching/binary_search.assets/binary_search_step0.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step1.png b/docs/chapter_searching/binary_search.assets/binary_search_step1.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step1.png rename to docs/chapter_searching/binary_search.assets/binary_search_step1.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step2.png b/docs/chapter_searching/binary_search.assets/binary_search_step2.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step2.png rename to docs/chapter_searching/binary_search.assets/binary_search_step2.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step3.png b/docs/chapter_searching/binary_search.assets/binary_search_step3.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step3.png rename to docs/chapter_searching/binary_search.assets/binary_search_step3.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step4.png b/docs/chapter_searching/binary_search.assets/binary_search_step4.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step4.png rename to docs/chapter_searching/binary_search.assets/binary_search_step4.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step5.png b/docs/chapter_searching/binary_search.assets/binary_search_step5.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step5.png rename to docs/chapter_searching/binary_search.assets/binary_search_step5.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step6.png b/docs/chapter_searching/binary_search.assets/binary_search_step6.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step6.png rename to docs/chapter_searching/binary_search.assets/binary_search_step6.png diff --git a/docs/chapter_binary_search/binary_search.assets/binary_search_step7.png b/docs/chapter_searching/binary_search.assets/binary_search_step7.png similarity index 100% rename from docs/chapter_binary_search/binary_search.assets/binary_search_step7.png rename to docs/chapter_searching/binary_search.assets/binary_search_step7.png diff --git a/docs/chapter_binary_search/binary_search.md b/docs/chapter_searching/binary_search.md similarity index 100% rename from docs/chapter_binary_search/binary_search.md rename to docs/chapter_searching/binary_search.md diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_naive.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_naive.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_naive.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_naive.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step1.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step1.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step1.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step1.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step2.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step2.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step2.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step2.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step3.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step3.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step3.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step3.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step4.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step4.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step4.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step4.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step5.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step5.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step5.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step5.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step6.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step6.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step6.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step6.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step7.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step7.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step7.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step7.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step8.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step8.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_edge_step8.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_edge_step8.png diff --git a/docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_right_edge.png b/docs/chapter_searching/binary_search_edge.assets/binary_search_left_right_edge.png similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.assets/binary_search_left_right_edge.png rename to docs/chapter_searching/binary_search_edge.assets/binary_search_left_right_edge.png diff --git a/docs/chapter_binary_search/binary_search_edge.md b/docs/chapter_searching/binary_search_edge.md similarity index 100% rename from docs/chapter_binary_search/binary_search_edge.md rename to docs/chapter_searching/binary_search_edge.md diff --git a/mkdocs.yml b/mkdocs.yml index fcfc369de..d0fc50e9b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -153,29 +153,32 @@ nav: - 5.2.   队列: chapter_stack_and_queue/queue.md - 5.3.   双向队列: chapter_stack_and_queue/deque.md - 5.4.   小结: chapter_stack_and_queue/summary.md - - 6.     二分查找: - - 6.1.   二分查找: chapter_binary_search/binary_search.md - - 6.2.   二分查找边界: chapter_binary_search/binary_search_edge.md - - 7.     散列表: - - 7.1.   哈希表: chapter_hashing/hash_map.md - - 7.2.   哈希冲突处理: chapter_hashing/hash_collision.md - - 7.3.   小结: chapter_hashing/summary.md - - 8.     树: - - 8.1.   二叉树: chapter_tree/binary_tree.md - - 8.2.   二叉树遍历: chapter_tree/binary_tree_traversal.md - - 8.3.   二叉树数组表示: chapter_tree/array_representation_of_tree.md - - 8.4.   二叉搜索树: chapter_tree/binary_search_tree.md - - 8.5.   AVL 树 *: chapter_tree/avl_tree.md - - 8.6.   小结: chapter_tree/summary.md - - 9.     堆: - - 9.1.   堆: chapter_heap/heap.md - - 9.2.   建堆操作 *: chapter_heap/build_heap.md - - 9.3.   小结: chapter_heap/summary.md - - 10.     图: - - 10.1.   图: chapter_graph/graph.md - - 10.2.   图基础操作: chapter_graph/graph_operations.md - - 10.3.   图的遍历: chapter_graph/graph_traversal.md - - 10.4.   小结: chapter_graph/summary.md + - 6.     散列表: + - 6.1.   哈希表: chapter_hashing/hash_map.md + - 6.2.   哈希冲突处理: chapter_hashing/hash_collision.md + - 6.3.   小结: chapter_hashing/summary.md + - 7.     树: + - 7.1.   二叉树: chapter_tree/binary_tree.md + - 7.2.   二叉树遍历: chapter_tree/binary_tree_traversal.md + - 7.3.   二叉树数组表示: chapter_tree/array_representation_of_tree.md + - 7.4.   二叉搜索树: chapter_tree/binary_search_tree.md + - 7.5.   AVL 树 *: chapter_tree/avl_tree.md + - 7.6.   小结: chapter_tree/summary.md + - 8.     堆: + - 8.1.   堆: chapter_heap/heap.md + - 8.2.   建堆操作 *: chapter_heap/build_heap.md + - 8.3.   小结: chapter_heap/summary.md + - 9.     图: + - 9.1.   图: chapter_graph/graph.md + - 9.2.   图基础操作: chapter_graph/graph_operations.md + - 9.3.   图的遍历: chapter_graph/graph_traversal.md + - 9.4.   小结: chapter_graph/summary.md + - 10.     搜索算法: + - 10.1.   二分查找(New): chapter_searching/binary_search.md + - 10.2.   二分查找边界(New): chapter_searching/binary_search_edge.md + - 10.3.   哈希优化策略: chapter_searching/replace_linear_by_hashing.md + - 10.4.   重识搜索算法: chapter_searching/searching_algorithm_revisited.md + - 10.5.   小结: chapter_searching/summary.md - 11.     排序算法: - 11.1.   排序算法: chapter_sorting/sorting_algorithm.md - 11.2.   冒泡排序: chapter_sorting/bubble_sort.md @@ -186,16 +189,12 @@ nav: - 11.7.   计数排序: chapter_sorting/counting_sort.md - 11.8.   基数排序: chapter_sorting/radix_sort.md - 11.9.   小结: chapter_sorting/summary.md - - 12.     搜索算法: - - 12.1.   搜索算法(New): chapter_searching/searching_algorithm_revisited.md - - 12.2.   哈希优化策略: chapter_searching/replace_linear_by_hashing.md - - 12.3.   小结: chapter_searching/summary.md - - 13.     回溯算法: - - 13.1.   回溯算法(New): chapter_backtracking/backtracking_algorithm.md - - 13.2.   全排列问题(New): chapter_backtracking/permutations_problem.md - - 13.3.   N 皇后问题(New): chapter_backtracking/n_queens_problem.md - - 14.     附录: - - 14.1.   编程环境安装: chapter_appendix/installation.md - - 14.2.   一起参与创作: chapter_appendix/contribution.md + - 12.     回溯算法: + - 12.1.   回溯算法(New): chapter_backtracking/backtracking_algorithm.md + - 12.2.   全排列问题(New): chapter_backtracking/permutations_problem.md + - 12.3.   N 皇后问题(New): chapter_backtracking/n_queens_problem.md + - 13.     附录: + - 13.1.   编程环境安装: chapter_appendix/installation.md + - 13.2.   一起参与创作: chapter_appendix/contribution.md - 参考文献: - chapter_reference/index.md