Category Archives: Algorithms

Worst Case Scenario for QuickSort

Take a look at the following code: 1: var sw = new Stopwatch(); 2: sw.Start(); 3: Enumerable.Range(0, 3).SelectMany((i) => Enumerable.Range(0, 50000)).OrderBy(i => i).ToList(); 4: Console.WriteLine(sw.ElapsedMilliseconds); 5:  6: sw.Reset(); 7: sw.Start(); 8: Enumerable.Range(0, 2).SelectMany((i) => Enumerable.Range(0, 50000)).OrderBy(i => i).ToList(); 9: Console.WriteLine(sw.ElapsedMilliseconds); … Continue reading

Posted in Algorithms, C# | Leave a comment