I am writing a simple codec. The tree will be precomputed and there wont be any changes once its build. It will just be searched.
All the leaf nodes of a balanced binary tree are the signal values and internal nodes are the approximated compressed representations.
Is a list implementation using stl vector scalable if I have a large value of leaf nodes?
Currently I dont know how large large is.
List implementation e.g. 1,2,3,4,5,6,7
if I have 4 leaf nodes
then children of
root(1)-> 2,3
2->4,5
3->6,7
so I can simply jump to the children using their position in the vector.
Using a “list” or “array” should not pose any issue in this case (since the tree is immutable). The only requirement for O(log n) search is quick random access (ie, O(1) access to a given index).
You can use either a
vectoror adeque, both are suitable. You might run in a scalability issue with thevectorif the system cannot find a large enough memory block to hold all elements, though to begin with it should prove simpler. If you hit this roadblock, switch todeque, and although you might lose some speed, it should allow you to grow further due to its fragmented nature.