Skip to content

Conversation

@rhettinger
Copy link
Contributor

No description provided.

@Yossarian0916
Copy link

The names _shiftdown and _shiftup are misleading and they should be exchanged. While building a min-heap, each element is compared with its child elements so to bubble it down, not 'up'.

@tim-one
Copy link
Member

tim-one commented Aug 31, 2019

The names should not be changed, because they're essentially arbitrary, with no compelling reason to favor one over the other - and there's no consistency about this in the literature either.

For example, when building a min-heap, the vast majority of elements that move go up in the heap, not down. It's only the single element at the top of the current sub-heap that moves down.

Which is the heart of the inherent ambiguity: something can't "go up" without something else "going down". The current names reflect the directions of the bulk of the data that moves (_siftup() generally moves children up to the their parent positions, and _siftdown() the opposite).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants