Question on a Heap Variation

Правка en1, от trickster0, 2022-10-11 01:38:00

How tractable is it to implement a min/max heap, such that all the nodes on all levels are sorted say from left to right?

This obviously doesn't need to break the main property of a heap, each parent is the min/max of its children. For instance:

If we make a min heap out of the numbers 1,2,3,4,5

We could get this valid heap: 1 / \ 3 2 / \ / \ 5 6 4

Is it possible to modify the implementation so that we always get something similar to this: 1 / \ 2 3 / \ / \ 4 5 6

And can we keep the complexity of insertion & deletion at O(log n)?

Теги heaps, sorting

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский trickster0 2022-10-11 01:38:00 677 Initial revision (published)