What is the advantage of mapping hash instead of the binary tree?
What is the advantage of mapping hash instead of the binary tree?
Doubt should be more the reverse.
If you need the data to be sorted you need the binary tree. If you need to order, you need an array , or some trick with the binary tree (or not). If you can neglect order or sorting then the spreadsheet can be useful.
The spreading table has complexity O (1), that is, it is constant no matter the volume of data. It's like the access time of an arrya by its index. Not the same time because hash needs to compute the bucket where the data is before accessing.
The binary tree has complexity O (logN) which in many cases is close to constant. In fact because it does not have to calculate with low data volume it is possible that it is faster than hash , even if logN gives something greater than 1. In large volumes it will be slower, but it is not a difference so great. To get an idea 1 billion elements can be accessed in only 30 steps. Although the volume influences the access time, it is ridiculous, and in some cases it makes no difference.