You could call it a bubble sort in a sorted array (O( n )) I guess. Except you're only looking at log n items. The splice is not more efficient. You need to move the entire array down one position to move a new element at the front. With a heap, you need to swap at most log n elements.
Google found me a good explanation of heaps. Look at the illustrations. It also explains storage of complete binary trees in an array.
Please do pick up a book or two on algorithms and data structures; this is stuff anyone who is serious about programming should know.
Makeshifts last the longest.
In reply to Re^7: Re-orderable keyed access structure?
by Aristotle
in thread Re-orderable keyed access structure?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |