Skip to content

Commit bd3031b

Browse files
committed
Added Odd Even Sort
1 parent 02d071f commit bd3031b

29 files changed

+104
-30
lines changed
23 KB
Binary file not shown.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<a href="https://scrutinizer-ci.com/g/pH7Software/pH7-Social-Dating-CMS/build-status/master">
99
<img src="https://scrutinizer-ci.com/g/pH7Software/pH7-Social-Dating-CMS/badges/build.png?b=master">
1010
</a>
11-
<a href="https://img.shields.io/badge/version-v1.03-blue">
12-
<img src="https://img.shields.io/badge/version-v1.03-blue">
11+
<a href="https://img.shields.io/badge/version-v1.04-blue">
12+
<img src="https://img.shields.io/badge/version-v1.04-blue">
1313
</a>
1414
<a href="https://github.com/nathanjukes/Sorting-Algorithm-Visualisation/blob/master/LICENSE.md">
1515
<img src="https://img.shields.io/github/license/Naereen/StrapDown.js.svg">
@@ -34,6 +34,8 @@ Or download here:
3434

3535
## Change Log
3636

37+
- 1.04 - Added Odd-Even Sort
38+
3739
- 1.03 - Added Gnome Sort, Changed GUI Sizing
3840

3941
- 1.02 - Added Comb Sort
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SortingAlgorithmVisualisation.Algorithms
8+
{
9+
class OddEvenSort : AlgorithmBase
10+
{
11+
public override int elementCount { get; set; }
12+
13+
public override void BeginAlgorithm(int[] elements)
14+
{
15+
elementCount = elements.Length;
16+
17+
StartOddEvenSort(elements);
18+
19+
DisplaySort.SortComplete = true;
20+
21+
ShowCompletedDisplay(graphics, maxWidth, maxHeight, elements, threadDelay);
22+
}
23+
24+
private void StartOddEvenSort(int[] elements)
25+
{
26+
for(int i = 0; i < (elementCount / 2) + 1; i++)
27+
{
28+
SortOddOrEven(elements, 1);
29+
30+
SortOddOrEven(elements, 0);
31+
}
32+
}
33+
34+
private void SortOddOrEven(int[] elements, int modOffset)
35+
{
36+
for(int i = 0; i < elementCount; i++)
37+
{
38+
if(i % 2 == modOffset)
39+
{
40+
if(i + 1 < elementCount && elements[i] > elements[i + 1])
41+
{
42+
SwapElements(i, i + 1, elements, 0);
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}

SortingAlgorithmVisualisation/Forms/MainMenuForm.Designer.cs

Lines changed: 32 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SortingAlgorithmVisualisation/Forms/MainMenuForm.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ private bool SetAlgorithmData()
139139
algorithm.timeComplexity = ("O(n²)");
140140
algorithm.spaceComplexity = ("O(1)");
141141
break;
142+
case "OddEven Sort":
143+
algorithm = new OddEvenSort();
144+
algorithm.timeComplexity = ("O(n²)");
145+
algorithm.spaceComplexity = ("O(1)");
146+
break;
142147
case null:
143148
MessageBox.Show("Please select an algorithm","Error");
144149
return false;

SortingAlgorithmVisualisation/SortingAlgorithmVisualisation.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<Compile Include="Algorithms\HeapSort.cs" />
8686
<Compile Include="Algorithms\InsertionSort.cs" />
8787
<Compile Include="Algorithms\MergeSort.cs" />
88+
<Compile Include="Algorithms\OddEvenSort.cs" />
8889
<Compile Include="Algorithms\QuickSort.cs" />
8990
<Compile Include="Algorithms\RadixSort.cs" />
9091
<Compile Include="Algorithms\SelectionSort.cs" />

SortingAlgorithmVisualisation/bin/Debug/SortingAlgorithmVisualisation.application

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
1515
</dsig:Transforms>
1616
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
17-
<dsig:DigestValue>IdH0Z6J89ptJJMIA1NwRlsfl1wj4KcWAUmTs16ssUbo=</dsig:DigestValue>
17+
<dsig:DigestValue>qGsPZ30xKFPlDgjcVVyWGSKf2aHGrzpf5IY1JLKUbyI=</dsig:DigestValue>
1818
</hash>
1919
</dependentAssembly>
2020
</dependency>
Binary file not shown.

SortingAlgorithmVisualisation/bin/Debug/SortingAlgorithmVisualisation.exe.manifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
</dependentAssembly>
4343
</dependency>
4444
<dependency>
45-
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="SortingAlgorithmVisualisation.exe" size="625672">
45+
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="SortingAlgorithmVisualisation.exe" size="626696">
4646
<assemblyIdentity name="SortingAlgorithmVisualisation" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
4747
<hash>
4848
<dsig:Transforms>
4949
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
5050
</dsig:Transforms>
5151
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
52-
<dsig:DigestValue>AMN7A4Z4DtBIYj3gABsm26oeRM0Ze99cO1/rly5TFEc=</dsig:DigestValue>
52+
<dsig:DigestValue>JqWDp9YGUyQCnckAgzvcpzoePQJ8tYByCR0irr/uffk=</dsig:DigestValue>
5353
</hash>
5454
</dependentAssembly>
5555
</dependency>
Binary file not shown.

0 commit comments

Comments
 (0)