-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
157 lines (117 loc) · 3.68 KB
/
Main.cs
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using System.Diagnostics;
using System.Collections.Generic;
using Algorithms.Trees;
using Algorithms.HashTable;
namespace Algorithms
{
class MainClass
{
private static Stopwatch stw=new Stopwatch();
private static Random random = new Random();
public static void Main (string[] args)
{
/* HTable<string, int> ht = new HTable<string, int>(37);
int noElements=15;
Random rnd = new Random();
var _elements = new int[noElements];
for (int i=0; i<noElements; i++) {
_elements [i] = rnd.Next (noElements*100);
//_elements [i] = 1;
}
foreach (var e in _elements) {
try{
ht.Add(getRandomString(), e);
}
catch{}
}
ht.Add("tomaz", 99999);
ht.PrintTable();
Console.Out.WriteLine("tomaz: "+ht.GetValue("tomaz"));*/
//sorting();
/*BinaryCode bc = new BinaryCode();
bc.decode("12221112222221112221111111112221111");*/
/*Lottery l = new Lottery();
string [] rules = new string[]{"INDIGO: 93 8 T F",
"ORANGE: 29 8 F T",
"VIOLET: 76 6 F F",
"BLUE: 100 8 T T",
"RED: 99 8 T T",
"GREEN: 78 6 F T",
"YELLOW: 75 6 F F"};
l.sortByOdds(rules);
*/
/*Bonuses b = new Bonuses();
b.getDivision(new int[]{485, 324, 263, 143, 470, 292, 304, 188, 100, 254, 296,
255, 360, 231, 311, 275, 93, 463, 115, 366, 197, 470});*/
ImageDithering id = new ImageDithering();
id.count("ACEGIKMOQSUWY", new string[]{"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX",
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX",
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX",
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX",
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX",
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX"});
}
private static string getRandomString ()
{
var chars = "ABCČDEFGHIJKLMNOPQRSSTUVWXYZŽ0123456789";
var stringChars = new char[8];
for (int i = 0; i < stringChars.Length; i++)
{
stringChars[i] = chars[random.Next(chars.Length)];
}
return new String(stringChars);
}
private static void trees ()
{
BSTRee<int> tree = new BSTRee<int>();
tree.insertNode(5);
tree.PrintTreePostOrder();
tree.insertNode(2);
tree.PrintTreePostOrder();
tree.insertNode(8);
tree.PrintTreePostOrder();
tree.insertNode(4);
tree.PrintTreePostOrder();
tree.insertNode(9);
tree.PrintTreePostOrder();
tree.insertNode(3);
tree.PrintTreePostOrder();
tree.insertNode(1);
tree.PrintTreePostOrder();
tree.PrintTreePreOrder();
tree.PrintTreeInOrder();
tree.PrintTreePostOrder();
}
private static void sorting()
{
Random rnd = new Random();
int noElements=100000;
var _elements = new int[noElements];
for (int i=0; i<noElements; i++) {
_elements [i] = rnd.Next (noElements*2);
//_elements [i] = 1;
}
var _elements2=new int[noElements];
Array.Copy(_elements, _elements2, noElements);
var _elements3=new int[noElements];
Array.Copy(_elements, _elements3, noElements);
var _elements4=new int[noElements];
Array.Copy(_elements, _elements4, noElements);
/*Console.WriteLine ("Hello .NET Sort!");
stw.Start();
Array.Sort(_elements3);
stw.Stop();
var sp = stw.ElapsedMilliseconds;
Console.WriteLine(string.Format("Sorted {0} elements.", noElements));
Console.WriteLine(string.Format("Time taken: {0}", sp));
Console.WriteLine ("Hello MergeSort!");
MergeSort ms = new MergeSort(_elements2, noElements);
Console.WriteLine ("Hello QuickSort!");
QuickSort qs = new QuickSort(_elements, noElements);*/
Console.WriteLine ("Hello HeapSort!");
HeapSort hs = new HeapSort(_elements, noElements, true);
HeapSort hs2 = new HeapSort(_elements2, noElements, false);
}
}
}