language agnostic - Optimizing binary tree inserts to O(1) with hash map for write heavy trees -
First of all, I believe that while thinking about this, I've missed something major, but I still see about it If I did not really remember anything, then with it ...
I have a very heavy binary tree (about 50/50 writes and writes), and the way home From today I was thinking about ways to optimize it, especially writing that write faster - There is what I came up with.
Given that the first T (T, X) to add the operation joint (T, X) to the tree in X, to see whether X is already present, and in that case It does not return the parents back, so that we can add it instead of one of the parents' empty leaves.
What if we are in the process of adding an intermediate cache to a hash table, so when we add (T, X) what really happens, that is in the x hash and hash map M is inserted. And that's it. Optimization occurs when we ask to find elsewhere (T, X), now when we search for trees, we will reach a leaf node, because x is not yet planted (it is only hash map I exist in, we do the keys of Hash X and M to compare it to see if it should be in the tree. If it is found in M, then we add it to the tree and remove it from M.
This will eliminate the operation (T, X) on AD (T, X) and add to it (M, X) which is O (1). And then (AB) - Use the search (T, X) operation when we first find it to insert the node to insert it.
Why not use hashtable for everything and completely leave the binary tree?
It all depends on why you were using binary trees earlier in the place. If you choose binary trees to increase the share, then you lose from the hashable cache because hashtables are not shared. Edit:
Edit:
Edit:
Edit:
If operation If you take advantage of the specialty of the trees, then rarely (you mention RB trees take advantage of the facts to be solved) and, on the other hand, you often see a key that has been recently added, or a key The place of value that has been recently added, a small-sized cache applied with another structure Can be obtained means. You can also use a toothalite presentation in a tree, sometimes with a conversion.
The extra complexity of this cache layer can mean that you can not take advantage of practice at any time, or are not enough to repay the technical, having an ad-hoc data structure like this. Debt.
Comments
Post a Comment