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:

  1. check if container has object
  2. if yes, object, else create new object , add map
  3. 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

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -