Suppose, I have such a data structure
NavigableMap<Long, NavigableMap<Long, Set<String> map = new TreeMap<>();
And I want to calculate the complexity for the algorithm below:
SortedSet<Widget> result = new TreeSet<>();
map.tailMap(first, true)
.forEach( (k, v)-> {
v.headMap(second, true)
.forEach((key, value) -> result.addAll(value));
});
This is correct, that complexity will be equal to
O(log (n + k) * (log (k + m) + log (m))) ?
Where
- n - count of elements in original map
- k - count of elements in tailMap(first, true)
- m - count of elements in headMap(second, true)