IBM Interview Questions
Qu1: What is hashing and how it works??? Answer : Hashing means using some function or algorithm to map object data to some representative integer value. This so-called hash code (or simply hash ) can then be used as a way to narrow down our search when looking for the item in the map . How hashing works Purely as an example to help us grasp the concept, let's suppose that we want to map a list of string keys to string values (for example, map a list of countries to their capital cities). So let's say we want to store the data in Table 1 in the map. Key Value Cuba Havana England London France Paris Spain Madrid Switzerland Berne Table 1: Example data to put in a map And let's suppose that our hash function is to simply take the length of the string. For simplicity, we'll have two arrays: one for our keys and one for the values. So to put an item in the hash table, we compute its hash code (in this case, simply count the number of characters), then put the ke...