Cc quick sort code demo

From , 5 Years ago, written in C#, viewed 83 times.
URL https://pastebin.vip/view/137bdd55
  1. private static int Partition (int[] list, int i, int j)
  2. {
  3.     int Key = list [i];
  4.  
  5.     while (i < j)
  6.     {
  7.         //j to the left scan
  8.         while (list [j] >= Key && i < j)
  9.             j--;
  10.  
  11.         if(i< j)
  12.             list [i++] = list [j];
  13.  
  14.         //i to the right scan
  15.         while (list [i] <= Key && i < j)
  16.             i++;
  17.  
  18.         IF (i < j)
  19.             list [j--] = list[i];
  20.     }
  21.  
  22.     list [i] = Key;
  23.     return i;
  24. }
  25. public static void QuickSort (int[] list, int low, int high)
  26. {
  27.     if(low < high - 1)
  28.     {
  29.         int Key = Partition (list, low, high);
  30.         QuickSort (list, low, Key - 1);
  31.         QuickSort (list, Key + 1, high);
  32.     }
  33. }
  34. //csharp/7785

Reply to "Cc quick sort code demo"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website