Skip to content

Контрольная 2. Разгуляева Ада #10

Open
ada1ra wants to merge 3 commits intomainfrom
kr_2
Open

Контрольная 2. Разгуляева Ада #10
ada1ra wants to merge 3 commits intomainfrom
kr_2

Conversation

@ada1ra
Copy link
Owner

@ada1ra ada1ra commented Dec 12, 2025

No description provided.

@ada1ra ada1ra requested a review from chernishev December 12, 2025 14:58
Copy link

@Godrik0 Godrik0 left a comment

Choose a reason for hiding this comment

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

  • -5 баллов за ошибки в логике _union
  • +2 балла за тесты
  • +2 балла за decrease
    Итого 29/30


def _union(self, other_heap):
"""Слияние двух биномиальных куч"""
merged_head = self._merge_root_lists(self.head, other_heap.head)
Copy link

Choose a reason for hiding this comment

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

_merge_root_lists ничего не возвращает, а значит дальнейшее выполнение функции неверно


while next_node:
# степени разные или три дерева подряд одинаковой степени
if x.degree != next_node.degree or (next_node.sibling == x.degree and next_node.sibling.degree == x.degree):
Copy link

Choose a reason for hiding this comment

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

next_node.sibling -- это объект, x.degree -- это число, их сравнение всегда будет False. Нужно было проверять что next_node.sibling это не None.

Comment on lines +156 to +157
decrease(self, node, -10**9)
extract_min(self)
Copy link

Choose a reason for hiding this comment

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

def delete(self, node):
        self.decrease(node, -float('inf'))
        self.extract_min()

Comment on lines +141 to +157
def decrease(self, node, value):
"""Уменьшает ключ элемента, присваивая новое значение"""
if value > node.key:
return
node.key = value
parent = node.parent
while parent and node.key < parent.key:
node.key, parent.key = parent.key, node.key
node.value, parent.value = parent.value, node.value

node = parent
parent = node.parent

def delete(self, node):
"""Удаление ключа"""
decrease(self, node, -10**9)
extract_min(self)
Copy link

Choose a reason for hiding this comment

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

Эти методы ожидают объект node, но ни один публичный метод не возвращает его, мы просто не сможем никак вызвать heap.decrease() или heap.delete().

Copy link

Choose a reason for hiding this comment

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

Ruff ругается

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