forked from krahets/hello-algo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.Please remove all the unused libs for every files
2.add a file header for all the files
- Loading branch information
zhuzhiqing
committed
Dec 23, 2022
1 parent
a427cb1
commit 7b538ce
Showing
27 changed files
with
175 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
using Newtonsoft.Json.Linq; | ||
/** | ||
* File: list.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
|
||
namespace hello_algo.chapter_array_and_linkedlist | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using Newtonsoft.Json.Linq; | ||
/** | ||
* File: my_list.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace hello_algo.chapter_array_and_linkedlist | ||
{ | ||
|
13 changes: 7 additions & 6 deletions
13
codes/csharp/chapter_computational_complexity/leetcode_two_sum.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
/** | ||
* File: leetcode_two_sum.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_computational_complexity | ||
{ | ||
|
13 changes: 7 additions & 6 deletions
13
codes/csharp/chapter_computational_complexity/space_complexity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
using hello_algo.include; | ||
/** | ||
* File: space_complexity.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace hello_algo.chapter_computational_complexity | ||
{ | ||
|
8 changes: 7 additions & 1 deletion
8
codes/csharp/chapter_computational_complexity/time_complexity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
using NUnit.Framework; | ||
/** | ||
* File: time_complexity.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_computational_complexity | ||
{ | ||
|
10 changes: 5 additions & 5 deletions
10
codes/csharp/chapter_computational_complexity/worst_best_time_complexity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
/** | ||
* File: worst_best_time_complexity.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
namespace hello_algo.chapter_computational_complexity | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
/** | ||
* File: array_hash_map.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System.Collections.Immutable; | ||
|
||
namespace hello_algo.chapter_hashing | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
|
||
/** | ||
* File: hash_map.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System.Collections.Immutable; | ||
|
||
namespace hello_algo.chapter_hashing | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
/** | ||
* File: binary_search.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_searching | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
using hello_algo.include; | ||
/** | ||
* File: hashing_search.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace hello_algo.chapter_searching | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
using hello_algo.include; | ||
/** | ||
* File: linear_search.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace hello_algo.chapter_searching | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
/** | ||
* File: bubble_sort.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_sorting | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
using NUnit.Framework; | ||
/** | ||
* File: insertion_sort.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_sorting | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
/** | ||
* File: merge_sort.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_sorting | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
/** | ||
* File: quick_sort.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_sorting | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
using System; | ||
using hello_algo.include; | ||
/** | ||
* File: array_queue.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_stack_and_queue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
using System; | ||
using hello_algo.include; | ||
/** | ||
* File: array_stack.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_stack_and_queue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
using System; | ||
/** | ||
* File: linkedlist_queue.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
using System; | ||
/** | ||
* File: linkedlist_stack.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
using System; | ||
using hello_algo.include; | ||
/** | ||
* File: queue.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_stack_and_queue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
/** | ||
* File: stack.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using NUnit.Framework; | ||
using System.Collections.Immutable; | ||
|
||
namespace hello_algo.chapter_stack_and_queue | ||
{ | ||
|
@@ -18,15 +22,15 @@ public void Test() | |
stack.Push(2); | ||
stack.Push(5); | ||
stack.Push(4); | ||
Console.WriteLine("栈 stack = " + String.Join(",", stack.ToImmutableArray())); | ||
Console.WriteLine("栈 stack = " + string.Join(",", stack.ToArray())); | ||
|
||
/* 访问栈顶元素 */ | ||
int peek = stack.Peek(); | ||
Console.WriteLine("栈顶元素 peek = " + peek); | ||
|
||
/* 元素出栈 */ | ||
int pop = stack.Pop(); | ||
Console.WriteLine("出栈元素 pop = " + pop + ",出栈后 stack = " + String.Join(",", stack.ToImmutableArray())); | ||
Console.WriteLine("出栈元素 pop = " + pop + ",出栈后 stack = " + string.Join(",", stack.ToArray())); | ||
|
||
/* 获取栈的长度 */ | ||
int size = stack.Count(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
using hello_algo.include; | ||
/** | ||
* File: avl_tree.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
|
||
namespace hello_algo.chapter_tree | ||
{ | ||
|
@@ -69,7 +74,7 @@ public int balanceFactor(TreeNode? node) | |
} | ||
|
||
/* 执行旋转操作,使该子树重新恢复平衡 */ | ||
private TreeNode? rotate(TreeNode? node) | ||
TreeNode? rotate(TreeNode? node) | ||
{ | ||
if (node == null) | ||
return node; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
/** | ||
* File: binary_search_tree.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
|
||
namespace hello_algo.chapter_tree | ||
{ | ||
|
@@ -31,11 +35,7 @@ internal class binary_search_tree | |
return cur; | ||
} | ||
|
||
/// <summary> | ||
/// 插入结点 | ||
/// </summary> | ||
/// <param name="num"></param> | ||
/// <returns></returns> | ||
/* 插入结点 */ | ||
TreeNode? insert(int num) | ||
{ | ||
// 若树为空,直接提前返回 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
/** | ||
* File: binary_tree.cs | ||
* Created Time: 2022-12-23 | ||
* Author: haptear ([email protected]) | ||
*/ | ||
|
||
using hello_algo.include; | ||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
|
||
|
||
namespace hello_algo.chapter_tree | ||
{ | ||
|
Oops, something went wrong.