Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fms12 authored Nov 28, 2022
2 parents 039e08f + d765977 commit 145ee5d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 48 deletions.
Empty file.
17 changes: 17 additions & 0 deletions Searching & sorting/Sorting/ShellSort/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Shell sort in python


def shellSort(array, n):

# Rearrange elements at each n/2, n/4, n/8, ... intervals
interval = n // 2
while interval > 0:
for i in range(interval, n):
temp = array[i]
j = i
while j >= interval and array[j - interval] > temp:
array[j] = array[j - interval]
j -= interval

array[j] = temp
interval //= 2
12 changes: 12 additions & 0 deletions Searching & sorting/Sorting/ShellSort/test_solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from .solution import shellSort
import pytest

print(pytest)

numbers = [9, 8, 3, 7, 5, 6, 4, 1]
Ans = sorted(numbers)


def test_sort_Asce():
shellSort(numbers,len(numbers))
assert numbers == Ans
48 changes: 0 additions & 48 deletions Searching & sorting/Sorting/Shellsort.py

This file was deleted.

0 comments on commit 145ee5d

Please sign in to comment.