Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E_Maksimova_lesson_04 #1258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

E_Maksimova_lesson_04 #1258

wants to merge 1 commit into from

Conversation

HelenMaksimova
Copy link

4 урок, Алгоритмы и структуры данных, старт 09.03.2021, Максимова Елена


print(f"Время выполнения: {timeit('func_2(test_list)', number=100000, globals=globals())}") # ~ 0.43

# Замеры показывают, что вторая функция действительно работает быстрее.
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.

лучшее выполнение за все время ведения курса

# использует встроенную функцию str и встроенный функционал срезов, реализованные наиболее оптимальным образом.
# Кроме того, третья функция не тратит время на множество промежуточных вычислений и переприсваиваний,
# в отличие от функции с циклом. Рекурсивная же функция работает медленнее всего по определению - из-за
# сложности рекурсивного алгоритма.
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено

return f'Чаще всего встречается число {max_elem}, ' \
f'оно появилось в массиве {result[max_elem]} раз(а)'


Copy link
Owner

Choose a reason for hiding this comment

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

отлично

# Сложность наивного и улучшенного наивного алгоритмов близка к квадратичной, но скорость работы улучшенного
# наивного алгоритма растёт гораздо медленнее и при малом значении i он будет быстрее, чем алгоритм с решетом,
# однако уже при i = 100 решето становится эффективнее.
# Сложность алгоритма решето Эратосфена O(n log(log n))
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