Skip to content

Commit ad92692

Browse files
author
ryuta69
committed
Fix name of is_surplus into has_last_odd_item
1 parent b7b66c3 commit ad92692

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sorts/merge_insertion_sort.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ def merge(left, right):
6868
return collection
6969

7070
two_paired_list = []
71-
is_surplus = False
71+
has_last_odd_item = False
7272
for i in range(0, len(collection), 2):
7373
if i == len(collection) - 1:
74-
is_surplus = True
74+
has_last_odd_item = True
7575
else:
7676
if collection[i] < collection[i + 1]:
7777
two_paired_list.append([collection[i], collection[i + 1]])
@@ -81,16 +81,16 @@ def merge(left, right):
8181
result = [i[0] for i in sorted_list_2d]
8282
result.append(sorted_list_2d[-1][1])
8383

84-
if is_surplus:
84+
if has_last_odd_item:
8585
pivot = collection[-1]
8686
result = binary_search_insertion(result, pivot)
8787

88-
is_surplus_inserted_before_this_index = False
88+
is_last_odd_item_inserted_before_this_index = False
8989
for i in range(len(sorted_list_2d) - 1):
9090
if result[i] == collection[-i]:
91-
is_surplus_inserted_before_this_index = True
91+
is_last_odd_item_inserted_before_this_index = True
9292
pivot = sorted_list_2d[i][1]
93-
if is_surplus_inserted_before_this_index:
93+
if is_last_odd_item_inserted_before_this_index:
9494
result = result[: i + 2] + binary_search_insertion(result[i + 2 :], pivot)
9595
else:
9696
result = result[: i + 1] + binary_search_insertion(result[i + 1 :], pivot)

0 commit comments

Comments
 (0)