We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 78d8a9b commit 27777e9Copy full SHA for 27777e9
allalgorithms/sorting/OddEvenSort.py
@@ -0,0 +1,26 @@
1
+# -*- coding: UTF-8 -*-
2
+#
3
+# OddEven Sort Algorithm
4
+# The All ▲lgorithms library for python
5
6
+# Contributed by: Cayo Viegas
7
+# Github: @CayoViegas
8
9
+
10
+def oddEvenSort(arr, n):
11
+ isSorted = 0
12
+ while isSorted == 0:
13
+ isSorted = 1
14
+ temp = 0
15
+ for i in range(1, n-1, 2):
16
+ if arr[i] > arr[i+1]:
17
+ arr[i], arr[i+1] = arr[i+1], arr[i]
18
19
20
+ for i in range(0, n-1, 2):
21
22
23
24
25
+ return arr
26
0 commit comments