1

What is the time complexity of Map.prototype.get if properties of map are objects?

const o1 = {v: 1};
const o2 = {v: 2};
const m = new Map();

m.set(o1, 'o1');
m.set(o2, 'o2');

m.get(o1) // Time complexity O(1)?
m.get(o2) // Time complexity O(1)?
sAs59
  • 562
  • 2
  • 7
  • 30
  • Possible duplicate of [es6 Map and Set complexity, v8 implementation](https://stackoverflow.com/questions/33611509/es6-map-and-set-complexity-v8-implementation). The answer is for V8 but it also states that the standard does not specify a required time complexity (only an upper bound). – meowgoesthedog Oct 23 '18 at 13:18

1 Answers1

0

Suppose n is the number of elements in the map, the average time complexity of finding an element is O(log(n)).

wleizny
  • 46
  • 5