Skip to content

070_lesson#7

Open
ikrugloff wants to merge 1 commit into
masterfrom
070_lesson
Open

070_lesson#7
ikrugloff wants to merge 1 commit into
masterfrom
070_lesson

Conversation

@ikrugloff
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@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.

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

Comment thread task_01.py
@@ -0,0 +1,21 @@
import random
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Похоже вы прослушали то, что было в конце урока.
В функцию не превратили, "ускоритель" не добавили. И сортирует по возрастанию, а не по убыванию.
Да, разворот внизу есть. Но с таким же успехом можно все задачи решить через sorted.

Comment thread task_02.py
@@ -0,0 +1,28 @@
import random
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 task_02.py
a_result = []
for i in range(N):
a_result.append(sum_(a[i]))
print(f'{a_result}')
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 task_03.py
M = 10
N = 2 * M + 1

l = [0] * N
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

l - без комментариев.

Comment thread task_03.py
:return: k-тый элемент l
"""
if len(l) == 1:
assert k == 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.

В половине запусков выпадаю тут с ошибкой

Comment thread task_03.py
x = sorted(l[:])
print(f'sorted_list = {x}')

# With love to https://habr.com/post/346930/
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 task_03.py

# With love to https://habr.com/post/346930/

def nlogn_median(l):
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 task_03.py
quickselect(l, len(l) / 2, pivot_fn))


def quickselect(l, k, pivot_fn):
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 task_03.py

print(f'n*logn median = {nlogn_median(l)}')
print(f'quickselect_median = {quickselect_median(l, pivot_fn=random.choice)}')
print(f'determine O(n) = {pick_pivot(l)}') # что-то здесь пошло не так с медианой???
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Привязка к 5.

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