The tree uses more time and memory. The difficulties are the same, but the constant factors are different.
Tree pointers use a lot of memory, compared to an array based on an array, where you hardly need any extra space, except that it is taken by the values โโthemselves. And manipulating these pointers takes time. Allocating and releasing nodes can take some time and space ...
In addition, there is no guarantee that tree nodes will be merged in memory. If either of the two alternatives uses a cache, this is a bunch of arrays.
comocomocomocomo
source share