java - Insert and Update in log(n) time with better performance -
i developing financial algorithms using java. have complex data structure many properties need updated during life time of algorithm. data structure updated more 1000 times ...
to improve performance get(search)/update/insert
decided use treemap
container quite efficient in regard.
now comes challenging part. need update data-structure properties need retrieve container requires:
- check if container has object
- if yes, object, else create new object , add map
- update object if present in container
this process takes 3 x log(n) i.e check, , put. want in single log(n) time.
for that, solution is:
i add object in map (insert/update/get
) using put
. put
returns old object, update current object old values, solves log(n) different object lost reference previous object because new value replaced in map.
is there better solution or better container updating datastructure. can use list
, use binary search of collections need sort datastructure again list not sorted.
kindly guide
i think doing pretty good.
o(k.log(n)) = o(log(n))
where k constant. time complexity o(log(n))
Comments
Post a Comment