Skip to content

Conversation

@iisat
Copy link
Owner

@iisat iisat commented Nov 18, 2018

No description provided.

Copy link

@Dzhoker1 Dzhoker1 left a comment

Choose a reason for hiding this comment

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

Оставил комментарии по коду

@@ -0,0 +1,71 @@
# Это просто материал урока, не дз

Choose a reason for hiding this comment

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

Не буду его проверять )))

import random

# Генерация массива размера SIZE с числами в диапазоне от MIN до MAX
def ar_gen(SIZE, MIN, MAX):

Choose a reason for hiding this comment

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

аргументы функции пишите строчными буквами. Они не могут быть константами по определению.

if array[i] > array[i + 1]:
array[i], array[i + 1] = array[i + 1], array[i]
subcount += 1
else: # Добавляем обратный проход для ускорения "всплытия" :)

Choose a reason for hiding this comment

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

Это называется шейкерная сортировка.
Уже не пузырёк.

while len(left) != 0 and len(right) != 0:
if left[0] < right[0]:
result.append(left[0])
left.remove(left[0])

Choose a reason for hiding this comment

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

Алгоритм верный.
Но одна эта строчка добавляет O(n) к сложности.
А у вас их две.

return array

def find_med(array):
source = array.copy()

Choose a reason for hiding this comment

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

Кроме сложности по времени решили добавить сложность по памяти.
Не завидую я компьютеру, когда на вход придёт массив в 10 Гб.

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.

3 participants