Domanda di colloquio di Fiverr Inc.

describe the differences between a hashmap and an array considering memory, performance and uses

Risposta di colloquio

Anonimo

5 gen 2018

1. arrays guarantee an O(1) fetch time while hashmap can fetch element in O(1) - best case or O(n) - worst case. 2. arrays also guarantee an order where hashmap dont. 3.array allows duplicate values, hashmap allows duplicate value but not keys 4. hashmaps will consume more memory since it need to store keys and values where arrays stores only values