News for hackers. Stuff that matters.
Re:Google Interview University – Plan for studying to become... by rand_r on Thursday October 06, 2016 @10:10AM (#12652555)
In context, n is the number of things in the hashmap. You need log2(n) bits per item to store n unique items. So the hash function is operating on an input of log2(n) bits. There's no way the hash function takes less than log2(n) time to work on log2(n) bits of input.
Re:Google Interview University – Plan for studying to become... by lkitching on Thursday October 06, 2016 @10:44AM (#12652845)
You don't need hash codes to be unique for items in the table so there doesn't need to be any relation between the size of the hash and the size of the table. The time taken by the hash function depends on the size of the keys not the size of the table.
Re:Google Interview University – Plan for studying to become... by rand_r on Thursday October 06, 2016 @10:49AM (#12652907)
If they're not unique, it will have to linearly search through items with duplicate keys. This situation will begin to approach O(n) time, which isn't good.
Re:Google Interview University – Plan for studying to become... by krona on Thursday October 06, 2016 @11:07AM (#12653101)
Unless you're using an Open addressing scheme like cookoo which ensures constant lookup time in the worst case
Re:Google Interview University – Plan for studying to become... by to3m on Thursday October 06, 2016 @10:58AM (#12653010)
If the cost of a hash function is related to anything, it is more usually the number of bits in the input.