Skip to content

Conversation

@Marsupilami-it
Copy link

No description provided.

is_sort = False # если были переставлены элементы, то массив считается не отсортированным
if is_sort: # в теле цикла проверили были ли изменения, прошли по всему массиву, если всё ок, ты выходим.
break
'''
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давайте сделаем итоговый вывод, есть ли смысл модифицировать пузырек?

'''
Применена оптимизация естественности поведения.
На вход дан упорядоченный массив данных, и сортировать его не нужно.
Работает данная оптимизация с помощью:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нина, а зачем на вход подавать упорядоченный массив?
зачем сортировка, если массив уже упорядочен
нужно передавать неупорядоченный


print(data)
merge_sort(data)
print(data)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

слияние реализовано

print(f'Медиана = {median(data)}')
print(data)
print(sorted(data))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь тоже хороши бы итоговые выводы - применили сортировку или нет и т.д.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants