Algorithms: Customization Binary Search

I had some interviews into big companies like Google, Amazon and so on, and there were tasks related to the algorithms. So, Here I’ll describe one of the tasks and publish code for this algorithm. Note, during interview you can chose algorithm by your self and time for implementation (runtime implementation) about 30 mins…..

Predefined: There is dictionary of words with unspecified size, we just know that all words in dictionary are sorted (for example by alphabet). Also we have just a one method

Needs: Need to develop algorithm to find some input word in dictionary using java. For this we should implement method

Limitations: We cannot change the internal structure of dictionary, we have no access to internal structure, we do not know counts of elements in dictionary.

Issues: I have developed modified-binary search, But you can try to implement interpolation search or modification interpolation + binary 🙂 .

So, my code :

I hope this post will help some one to pass interview into the biggest companies 🙂


Read Also:  Generate a file with random numbers in Python

Leave a Reply

Your email address will not be published. Required fields are marked *