Skip to content

add HeapSort and Test_heap_sort#28

Open
Quark1111 wants to merge 14 commits intomainfrom
Sorting
Open

add HeapSort and Test_heap_sort#28
Quark1111 wants to merge 14 commits intomainfrom
Sorting

Conversation

@Quark1111
Copy link
Owner

No description provided.

@Quark1111 Quark1111 requested a review from chernishev December 12, 2025 16:49
Comment on lines +23 to +28
def test_negative():
assert HeapSort([32, 11, 12, 14, -10, 0, 9, 0, 0, 0, -7, 112, 3, -110]) == [-110, -10, -7, 0, 0, 0, 0, 3, 9, 11, 12, 14, 32, 112]




Copy link

Choose a reason for hiding this comment

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

Отсутствуют property based тесты с другими сортировками

Comment on lines +1 to +25
def heapify(mas, n, i):
largest = i
left = i*2 + 1
right = i*2 + 2

if left < n and mas[largest] < mas[left]:
largest = left
if right < n and mas[largest] < mas[right]:
largest = right

if largest != i:
mas[i], mas[largest] = mas[largest], mas[i]
heapify(mas, n, largest)
def HeapSort(mas):
n = len(mas)

for i in range(n // 2 - 1, -1, -1):
heapify(mas, n, i)

for i in range(n - 1, -1, -1):
mas[0], mas[i] = mas[i], mas[0]
heapify(mas, i, 0)

return mas

Copy link

Choose a reason for hiding this comment

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

Проблемы с форматированием, в heapify у вас 8 пробелов, а в HeapSort -- 4
Так же нет двух строчек между функциями

if largest != i:
mas[i], mas[largest] = mas[largest], mas[i]
heapify(mas, n, largest)
def HeapSort(mas):
Copy link

Choose a reason for hiding this comment

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

Название функций в snake_case

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