Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit 32619ab

Browse files
Added the slowSort sorting algorithmic technique and code (#916)
Co-authored-by: ANUJ KUMAR <45460554+R3v3rb3@users.noreply.github.com>
1 parent d3e4d23 commit 32619ab

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
This slowSort is inplace sorting algorithm for an list of integer
3+
The idea behind it is,
4+
it divides an input list into two half, call itself into two half. and then compairs the maximum element
5+
of the two half. It store the maximum element of the subarray at the top of the position
6+
of the sub array . then it recursively call the subarray without the maximum elements.
7+
8+
"""
9+
10+
11+
12+
def slowSort(arr, left, right):
13+
14+
if left>=right:
15+
return
16+
17+
mid = (left+right)//2
18+
19+
slowSort(arr, left, mid)
20+
slowSort(arr, mid+1, right)
21+
22+
if arr[mid] > arr[right]:
23+
arr[mid], arr[right] = arr[right], arr[mid]
24+
25+
slowSort(arr, left, right-1)
26+

0 commit comments

Comments
 (0)