Conversation
Godrik0
reviewed
Dec 18, 2025
Godrik0
left a comment
There was a problem hiding this comment.
- -5 баллов за ошибки в логике
_union - +2 балла за тесты
- +2 балла за
decrease
Итого 29/30
|
|
||
| def _union(self, other_heap): | ||
| """Слияние двух биномиальных куч""" | ||
| merged_head = self._merge_root_lists(self.head, other_heap.head) |
There was a problem hiding this comment.
_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): |
There was a problem hiding this comment.
next_node.sibling -- это объект, x.degree -- это число, их сравнение всегда будет False. Нужно было проверять что next_node.sibling это не None.
Comment on lines
+156
to
+157
| decrease(self, node, -10**9) | ||
| extract_min(self) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Эти методы ожидают объект node, но ни один публичный метод не возвращает его, мы просто не сможем никак вызвать heap.decrease() или heap.delete().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.