From ac83f9505433064a2ed037b961e4d36c5098a58b Mon Sep 17 00:00:00 2001 From: Luke Else Date: Tue, 28 Sep 2021 09:59:42 +0100 Subject: [PATCH] New Quicksort Algorithm --- QuickSort/Program.cs | 12 +++++++ QuickSort/QuickSort.cs | 65 ++++++++++++++++++++++++++++++++++++++ QuickSort/QuickSort.csproj | 8 +++++ 3 files changed, 85 insertions(+) create mode 100644 QuickSort/Program.cs create mode 100644 QuickSort/QuickSort.cs create mode 100644 QuickSort/QuickSort.csproj diff --git a/QuickSort/Program.cs b/QuickSort/Program.cs new file mode 100644 index 0000000..00ccf9c --- /dev/null +++ b/QuickSort/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace QuickSort +{ + class Program + { + static void Main(string[] args) + { + + } + } +} diff --git a/QuickSort/QuickSort.cs b/QuickSort/QuickSort.cs new file mode 100644 index 0000000..10b7136 --- /dev/null +++ b/QuickSort/QuickSort.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace QuickSort +{ + public class QuickSort + { + public int[] List { get; set; } + + public QuickSort(int[] List){ + + } + + public int[] Sort(){ + + Pointer pivot = new Pointer(0, List); + + Pointer left = new Pointer(1, List); + + Pointer right = new Pointer(List.Length-1, List); + + while (right.Index >= left.Index) + { + while (left.Index <= right.Index && left.Value <= pivot.Value) + { + left.UpdatePointer(left.Index + 1, List); + } + while (right.Index >= left.Index & right.Value >= pivot.Value) + { + right.UpdatePointer(right.Index - 1, List); + } + if (right.Index > left.Index) + { + //Swap the values of both + swap(); + } + } + + return new int[1]{1}; + } + + + public void swap(){ + + } + } + + public class Pointer{ + public int Index { get; set; } + public int Value { get; set; } + + + public Pointer(int index, int[] list){ + this.Index = index; + this.Value = list[index]; + } + + public void UpdatePointer(int index, int[] list){ + this.Index = index; + this.Value = list[index]; + } + } +} \ No newline at end of file diff --git a/QuickSort/QuickSort.csproj b/QuickSort/QuickSort.csproj new file mode 100644 index 0000000..1d2d39a --- /dev/null +++ b/QuickSort/QuickSort.csproj @@ -0,0 +1,8 @@ + + + + Exe + net5.0 + + +