Skip to content

Lesson7 - #7

Open
iisat wants to merge 1 commit into
Lesson6from
lesson7
Open

iisat wants to merge 1 commit into
Lesson6from
lesson7

Conversation

@iisat

@iisat iisat commented Nov 18, 2018

Copy link
Copy Markdown
Owner

No description provided.

@Dzhoker1 Dzhoker1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread Lesson7/task0.py
@@ -0,0 +1,71 @@
# Это просто материал урока, не дз

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread Lesson7/task1.py
import random

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread Lesson7/task2.py
while len(left) != 0 and len(right) != 0:
if left[0] < right[0]:
result.append(left[0])
left.remove(left[0])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread Lesson7/task3.py
return array

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

Copy link
Copy Markdown

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.

2 participants