Skip to content
Open

1-2 #1269

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Урок 1. Практическое задание/task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def check_1(lst_obj):

Сложность: !!!.
Copy link
Owner

Choose a reason for hiding this comment

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

не оценена итоговая сложность

"""
lst_to_set = set(lst_obj) # !!!
lst_to_set = set(lst_obj) # !!! O(n)
return lst_to_set
Copy link
Owner

Choose a reason for hiding this comment

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

не оценена сложность здесь



Expand All @@ -41,12 +41,12 @@ def check_2(lst_obj):
что такой элемент отстутствует
в оставшихся справа элементах

Сложность: !!!.
Сложность: !!! O(n^2)
"""
for j in range(len(lst_obj)): # !!!
if lst_obj[j] in lst_obj[j+1:]: # !!!
return False # !!!
return True # !!!
for j in range(len(lst_obj)): # !!!O(n)
if lst_obj[j] in lst_obj[j+1:]: # !!!O(n)
return False # !!!O(1)
return True # !!!O(1)
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено



#############################################################################################
Expand All @@ -57,14 +57,14 @@ def check_3(lst_obj):
Вначале выполним для списка сортировку, далее, сравниваем элементы попарно
Если присутствуют дубли, они будут находиться рядом.

Сложность: !!!
Сложность: !!! O(n*log n)
"""
lst_copy = list(lst_obj) # !!!
lst_copy.sort() # !!!
for i in range(len(lst_obj) - 1): # !!!
if lst_copy[i] == lst_copy[i+1]: # !!!
return False # !!!
return True # !!!
lst_copy = list(lst_obj) # !!! O(n)
lst_copy.sort() # !!! O(N log N)
for i in range(len(lst_obj) - 1): # !!! O(n)
if lst_copy[i] == lst_copy[i+1]: # !!! O(1)
return False # !!! O(1)
return True # !!! O(1)
Copy link
Owner

Choose a reason for hiding this comment

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

выполнено


#############################################################################################

Expand Down
22 changes: 22 additions & 0 deletions Урок 1. Практическое задание/task_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,25 @@
Алгоритмизатор должен развивать мышление, а это прежде всего практика.
А без столкновения со сложностями его не развить.
"""


# O(n)
def minn_elem_1(spis):
Copy link
Owner

Choose a reason for hiding this comment

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

spis - это имя - транслитерация, что недопустимо по пеп-8

min_elem = spis[0]
for i in range(len(spis)):
if min_elem > spis[i]:
min_elem = spis[i]
return min_elem


# O(n^2)
def minn_elem_2(spis):
for i in spis:
true_min = True
for j in range:
if i > j:
true_min = False
if true_min:
return i


4 changes: 4 additions & 0 deletions Урок 1. Практическое задание/task_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@
Реализуйте поиск трех компаний с наибольшей годовой прибылью.
Выведите результат.
"""




Copy link
Owner

Choose a reason for hiding this comment

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

для получения оценки Хорошо нужно решить правильно хотя бы 4 задачи