Skip to content

Instantly share code, notes, and snippets.

@damianopetrungaro
Created March 27, 2021 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damianopetrungaro/08f28432eaaea574562c95dab9761190 to your computer and use it in GitHub Desktop.
Save damianopetrungaro/08f28432eaaea574562c95dab9761190 to your computer and use it in GitHub Desktop.
From max to min heap
```diff
< if h.items[parentIdx] <= h.items[idx] {
---
> if h.items[parentIdx] >= h.items[idx] {
```
```diff
< if lIdx < len(h.items) && h.items[lIdx] < h.items[idx] {
---
> if lIdx < len(h.items) && h.items[lIdx] > h.items[idx] {
```
```diff
< if rIdx < len(h.items) && h.items[rIdx] < h.items[idx] {
---
> if rIdx < len(h.items) && h.items[rIdx] > h.items[idx] {
```
```diff
< case h.items[idx] < h.items[rIdx] && h.items[idx] < h.items[lIdx]:
---
> case h.items[idx] > h.items[rIdx] && h.items[idx] > h.items[lIdx]:
```
```diff
< case h.items[rIdx] > h.items[lIdx]:
---
> case h.items[rIdx] < h.items[lIdx]:
```
```diff
< case h.items[rIdx] <= h.items[lIdx]:
---
> case h.items[rIdx] >= h.items[lIdx]:
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment