-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
97 lines (51 loc) · 1.85 KB
/
Program.cs
File metadata and controls
97 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Algorithms;
using System.Diagnostics;
using System.Reflection;
using static Algorithms.Search;
using static Algorithms.Sorting;
using static Algorithms.Recursion;
using Algorithms;
using static Algorithms.HashStructure<T>;
Random random = new Random();
Stopwatch stopwatch = new Stopwatch();
HashStructure<int> hashTable = new HashStructure<int>();
hashTable.Add("Adidas", 233);
hashTable.Add("Love", 233);
hashTable.Add("Marks", 233);
hashTable.Add("Jobele", 233);
hashTable.Add("Jacc", 233);
hashTable.Add("Jawcc", 233);
hashTable.Add("Jrwtacc", 233);
hashTable.Remove("Adidas");
hashTable.Remove("Love");
hashTable.Remove("Marks");
hashTable.Remove("Jobele");
int[] numberArray = new int[16];
for (int i = 0; i < numberArray.Length; i++)
{
//multiply a prime
numberArray[i] = 5 * random.Next(16);
}
int[] badCaseBinarySearch = new int[5] { 7, 7, 7, 7, 7 };
Array.Sort(numberArray);
var numberIsInArray = BinarySearch(numberArray, 17);
numberIsInArray = BinarySearch(badCaseBinarySearch, 2);
int[] unsortedNumberArray = new int[16];
for (int i = 0; i < unsortedNumberArray.Length; i++)
{
unsortedNumberArray[i] = 3 * random.Next(256);
}
Array.ForEach(unsortedNumberArray, element => Console.Write($"{element} "));
var sortedNumberArray = SelectionSortWithExtraStorage(unsortedNumberArray);
Console.WriteLine("\nSort:");
Array.ForEach(sortedNumberArray, element => Console.Write($"{element} "));
Console.WriteLine("\n");
Span<int> staticSpan = new int[5] { 1, 9, 3, 2, 5 };
int[] staticArray = new int[5] { 1, 9, 3, 2, 5 };
staticArray = SelectionSortInPlace(staticArray);
Array.ForEach(staticArray, element => Console.Write($"{element} "));
Console.WriteLine(Factorial(5));
Console.WriteLine(Sum(staticSpan, staticSpan.Length-1));
Console.WriteLine(CountItems(staticSpan, staticSpan.Length-1));
Console.ReadLine();