Spending a Million on RISC OS
GavinWraith (26) 1563 posts |
Your reference, Priority Queues with Binary Heaps, is just what I was looking for. Many thanks.
This is where Lua scores. Its table datatype is internally a cunning mixture of linear arrays and hashes so that extending arrays is optimized. See http://www.lua.org/doc/jucs05.pdf, or even the source code http://www.lua.org/source/5.2/ltable.c . |
Steve Drain (222) 1620 posts |
I understand that in theory a binary tree, heap or otherwise, is the most efficient method of storing ordered items. However, when dealing with a few1 items, the expense of maintaining a balanced tree is likely to outweigh the simplicity of an ordered linked list. As I suggested above, in BASIC a linked list is trivially simple, as it is in assembler. 1 What is a few? Perhaps a dozen or so timed events in any one application. This may not hold for OS_Call*, though, if it is offering the service to all-comers. |
Malcolm Hussain-Gambles (1596) 811 posts |
So is there going to be a new bounty “Lottery tickets” ;-) |
Steve Revill (20) 1361 posts |
What do you think RISC OS General is for…? ;) |
Steve Pampling (1551) 8170 posts |
Drinks at – insert hostelry of choice – ? |
h0bby1 (2567) 480 posts |
for binary tree , there are algorythm like red/black binary tree, or things like this, who can help to maintain always balanced tree for dynamically sorting big list, but i’m not sure there are lot of implementations of that. |
Malcolm Hussain-Gambles (1596) 811 posts |
Which reminds me! |
Steve Drain (222) 1620 posts |
That is interesting, but O(log(n)) for insert delete and read, only indicates a good measure of efficiency for large n. If n is small, the critical factor is the time taken by the the operations. Hence the use of linked lists, which are insert O(n), delete O(1) with a handle, and read first O(1). ;-) |