Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions sorts/bitonic_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def compAndSwap(a, i, j, dire):
# The sequence to be sorted starts at index position low,
# the parameter cnt is the number of elements to be sorted.
def bitonic_merge(a, low, cnt, dire):
if cnt > 1:
if cnt > 1:
k = int(cnt / 2)
for i in range(low, low + k):
compAndSwap(a, i, i + k, dire)
Expand Down Expand Up @@ -45,14 +45,12 @@ def sort(a, N, up):

if __name__ == "__main__":

a = []

n = int(input().strip())
for i in range(n):
a.append(int(input().strip()))
user_input = input("Enter numbers separated by a comma:\n").strip()
unsorted = [int(item) for item in user_input.split(",")]

up = 1

sort(a, n, up)
print("\n\nSorted array is")
for i in range(n):
print("%d" % a[i])
sort(unsorted,len(unsorted), up)
print("\nSorted array is")
print(*unsorted, sep=",")