People who code: we want your input. Take the Survey

New answers tagged


I think it would work with a complete tree with elements stored in leaves, the whole thing being stored in an array (the same way as for heaps). You also need to store in each node the sum of the weights of all its children. To be able to modify weight, you would also need a corresponding array (or hashtable if ids are not consecutive integers), to know ...

Top 50 recent answers are included