Skip to content
Closed
Changes from all commits
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
8 changes: 4 additions & 4 deletions insertion_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ def input_list():

def insertion_sort(list, n):
"""
sort list in assending order
sort list in ascending order

INPUT:
list=list of values to be sorted
n=size of list that contains values to be sorted

OUTPUT:
list of sorted values in assending order
list of sorted values in ascending order
"""
for i in range(0, n):
key = list[i]
j = i - 1
# Swap elements witth key iff they are
# Swap elements with key iff they are
# greater than key
while j >= 0 and list[j] > key:
list[j + 1] = list[j]
Expand All @@ -48,7 +48,7 @@ def insertion_sort_desc(list, n):
for i in range(0, n):
key = list[i]
j = i - 1
# Swap elements witth key iff they are
# Swap elements with key iff they are
# greater than key
while j >= 0 and list[j] < key:
list[j + 1] = list[j]
Expand Down