Skip to content

Comments

second kr python#32

Open
Gosha924 wants to merge 1 commit intomasterfrom
second_kr_python
Open

second kr python#32
Gosha924 wants to merge 1 commit intomasterfrom
second_kr_python

Conversation

@Gosha924
Copy link
Owner

No description provided.

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.

  • В логике merge серьезная ошибка (-8 баллов)
  • +2 балла за get_min
  • +2 балла за интерактивный режим
  • +2 балла за тесты
    Итого 28/30

Comment on lines +37 to +56
while i < len(self.trees) - 1:
current = self.trees[i]
after = self.trees[i + 1]
if current.order == after.order:
if (i + 1 < len(self.trees) - 1) and (self.trees[i + 2].order == after.order):
after2 = self.trees[i + 2]
if after.key < after2.key:
after.add_at_end(after2)
del self.trees[i + 2]
else:
after2.add_at_end(after)
del self.trees[i + 1]
else:
if current.key < after.key:
current.add_at_end(after)
del self.trees[i + 1]
else:
after.add_at_end(current)
del self.trees[i]
i = i + 1
Copy link

Choose a reason for hiding this comment

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

Если Вы объединили два дерева порядка k в дерево порядка k+1, оно может столкнуться со следующим деревом порядка k+1, которое уже есть в списке. Например, если слить кучу с деревьями $[B_0, B_1]$ с кучей $[B_0]$, то после объединения список будет $[B_1, B_1]$, но цикл завершится на i = 1 и в куче останется два дерева порядка 1.

Comment on lines +45 to +55
del self.trees[i + 2]
else:
after2.add_at_end(after)
del self.trees[i + 1]
else:
if current.key < after.key:
current.add_at_end(after)
del self.trees[i + 1]
else:
after.add_at_end(current)
del self.trees[i]
Copy link

@Godrik0 Godrik0 Dec 18, 2025

Choose a reason for hiding this comment

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

Из-за операции удаления сложность merge будет больше чем ожидаемые $\Omega(\log{n})$.

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