static void Main(string[] args) { //int[] arr = new int[] { 2, 5, -4, 11, 0, 18, 22, 67, 51, 6 }; int[] arr = createArr(1000, false, true, 0, 1100); Console.WriteLine("Original array : "); foreach (var item in arr) { Console.Write(" " + item); } Console.WriteLine(); // QuickSort.sort(arr, 0, arr.Length - 1); Stopwatch sw = new Stopwatch(); sw.Start(); HeapSort.sort(arr); sw.Stop(); Console.WriteLine(); Console.WriteLine("Sorted array : "); foreach (var item in arr) { Console.Write(" " + item); } Console.WriteLine(); Console.WriteLine("Time elapsed (ms): {0}", sw.Elapsed.TotalMilliseconds); }
static void Main(string[] args) { var tree1 = new Tree(1); var tree2 = new Tree(2); var tree3 = new Tree(3); var tree4 = new Tree(4); tree1.AddConnection(tree2); tree1.AddConnection(tree3); tree2.AddConnection(tree4); //tree4.AddConnection(tree1); BreadthFirstSearch.Traverse(tree1); DepthFirstSearch.Traverse(tree1); var binaryTreecoc = new BinaryTreeCocoon(); binaryTreecoc.Insert(100); binaryTreecoc.Insert(10); binaryTreecoc.Insert(200); binaryTreecoc.Insert(400); binaryTreecoc.Insert(50); binaryTreecoc.Insert(5); binaryTreecoc.Insert(8); binaryTreecoc.Insert(1); binaryTreecoc.Traverse(); binaryTreecoc.ReversTraverse(); binaryTreecoc.LeftViewTraverse(); binaryTreecoc.RightViewTraverse(); var linkedlist = new CustomLinkedList(1); linkedlist.Next = new CustomLinkedList(2); linkedlist.Next.Next = new CustomLinkedList(3); linkedlist.Next.Next.Next = linkedlist.Next; var ops = new LinkedListOperations(); Console.WriteLine("\r\nCheckCycle"); Console.WriteLine(ops.CheckIfCyclic(linkedlist)); ops.BreakCheckIfCyclic(linkedlist); var mimStack = new MinimumStackOrderOfOne(); Console.WriteLine("\r\nMinimumStack"); mimStack.Push(10); mimStack.Push(100); Console.WriteLine(mimStack.GetMinimum()); mimStack.Push(5); mimStack.Push(20); mimStack.Push(30); Console.WriteLine(mimStack.GetMinimum()); mimStack.Pop(); mimStack.Pop(); mimStack.Pop(); Console.WriteLine(mimStack.GetMinimum()); mimStack.Push(10000); mimStack.Push(50); var data = new SortedArrayToBST().Run(); var sortedss = SelectionSort.Sort(new int[] { 100, 200, 20, 4, 10, 35, }); Console.WriteLine($"\r\nSelectionSort : {JsonConvert.SerializeObject(sortedss)} \r\n"); var sortedis = InsertionSort.Sort(new int[] { 100, 200, 20, 4, 10, 35, }); Console.WriteLine($"\r\nInsertionSort : {JsonConvert.SerializeObject(sortedis)} \r\n"); var arr = new int[] { 100, 200, 20, 4, 10, 35, }; Console.WriteLine($"\r\nHeapSortSort Initials : {JsonConvert.SerializeObject(arr)} \r\n"); var sortedhs = HeapSort.Sort(arr); Console.WriteLine($"\r\nHeapSortSort : {JsonConvert.SerializeObject(sortedhs)} \r\n"); var ar2 = new int[] { 100, 200, 20, 4, 10, 35, }; var sortedhs2 = HeapSort.Sort2(ar2); Console.WriteLine($"\r\nHeapSortSortGeks : {JsonConvert.SerializeObject(sortedhs2)} \r\n"); var ar3 = new int[] { 100, 200, 20, 4, 10, 35, }; var sortedqs = QuickSort.Sort(ar2); Console.WriteLine($"\r\n QuickSort : {JsonConvert.SerializeObject(sortedqs)} \r\n"); Console.ReadKey(); }