using System; public class Test { public static void Main() { int [] data = GenerateData(3); Console.Write("Before:"); PrintArray(data); AnonSort(ref data); Console.Write("After:"); PrintArray(data); } private static int[] GenerateData(int length) { if (length > 3) throw new Exception("Are you fckn out of mind?"); int [] data = new int[length]; System.Random rand = new System.Random(); for(int i = 0; i < data.Length; i++) data[i] = rand.Next(10); return data; } private static void PrintArray(int[] data) { Console.Write("{"); for(int i = 0; i < data.Length; i++) { Console.Write(data[i]); if (i != data.Length - 1) Console.Write(", "); } Console.WriteLine("}"); } private static void AnonSort(ref int[] data) { Console.WriteLine($"Welcome to anon sort.\nWe have an array of {data.Length} elements. Let's sort this shit hard way!\n..."); //O (n*n) BubbleSort(ref data); //O (power(n!, n! + 1) + 2n + O(Math.Pow(n!, n! + 1))) = O (power(n!, n! + 1)) long counter = AlgorithmOptimization(data.Length); Console.WriteLine($"Anon sort complete.\nAlgorithm takes {counter}+ arithmetic operations."); } private static void BubbleSort(ref int[] data) { for(int i = 0; i < data.Length - 1; i++) for(int j = i + 1; j < data.Length; j++) { if(data[i] > data[j]) { int temp = data[i]; data[i] = data[j]; data[j] = temp; } } } private static long Factorial(long n) { long temp = 1; for (int i = 1; i <= n; i++) temp *= i; return temp; } private static long AlgorithmOptimization(int n) { long counter = new long(); long temp = (long)Math.Pow(Factorial(n), Factorial(n) + 1); for (long l = 0; l < temp; l++) counter++; return counter; } }