Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
quick sort
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { private int[] array = new int[20]; private int len; public void QuickSortAlgorithm() { sort(0, len - 1); } public void sort(int left, int right) { int pivot, leftend, rightend; leftend = left; rightend = right; pivot = array[left]; while (left < right) { while ((array[right] >= pivot) && (left < right)) { right--; } if (left != right) { array[left] = array[right]; left++; } while ((array[left] >= pivot) && (left < right)) { left++; } if (left != right) { array[right] = array[left]; right--; } } array[left] = pivot; pivot = left; left = leftend; right = rightend; if (left < pivot) { sort(left, pivot - 1); } if (right > pivot) { sort(pivot + 1, right); } } public static void Main(string[] args) { quickSortAlgorithm q_Sort = new quickSortAlgorithm(); int[] array = { 41, 32, 15, 45, 63, 72, 57, 43, 32, 52, 183}; q_Sort.array = array; q_Sort.len = q_Sort.array.Length; q_Sort.QuickSortAlgorithm(); for (int j = 0; j < q_Sort.len; j++) { Console.WriteLine(q_Sort.array[j]); } Console.ReadKey(); } } }
run
|
edit
|
history
|
help
0
priya
PermuteAString
OddEven
megha
Properties in Interfaces
Delegates, events
project euler 10, C#
Code which will convert Word into its Binary Format
c
cup tournament prediction