How to Select a Random Key from a Hash Map in Constant Time?

Premise A hashmap has a time complexity of O(1) for all operations. Problem You have to find a constant time method to uniformly random selection of a key in a Hash map. Assumptions The map can grow to memory size. You can use any readymade hash map. Solution I'm discussing the pseudo code for a…

%d bloggers like this: