Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #132

Open
wants to merge 2 commits into
base: Odintsova_Anastasia
Choose a base branch
from

Conversation

Anastasiya-Odintsova
Copy link

No description provided.

Воспользовалась помощью Кирилла Шестакова, если что
it[v] = val
return
middle = (r+l)//2
if indx < middle:
Copy link
Owner

Choose a reason for hiding this comment

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

Мы сравниваем индекс с серединой, если условие выполняется, то идем в левую часть дерева (т.е. именно там будем менять текущее значение с индексом indx на значение val). А изменение значения будет происходить, когда мы дойдем до листа (код 97-99).

s = get_sum(0, 0, n, it, l-1, r)
if s >= k and l > 1: #условие проверки на количество нулей
res.append(get_null(0, 0, n, it, k+get_sum(0, 0, n, it, 0, l-1)))
elif s >= k and l == 1:
Copy link
Owner

Choose a reason for hiding this comment

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

Что значит l > 1 и l == 1?

print(*heap)
result.append(extract(heap)) #здесь добавляем в конец результата значение. Я пробовала поменять на get_max() - вывод неправильный получился. Подскажите, как поменять на get_max()
result.reverse()
print(*result)
Copy link
Owner

Choose a reason for hiding this comment

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

    for i in range(N):
        print(*heap)
        result.append(get_max(heap))
        extract(heap)
    print(*result[::-1])

heap[0], heap[-1] = heap[-1], heap[0]
a = heap.pop()
shift_down(0, heap)
return a
Copy link
Owner

Choose a reason for hiding this comment

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

def extract(heap):
    heap[0], heap[-1] = heap[-1], heap[0]
    heap.pop()
    shift_down(0, heap)

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