Sort And Searching Question:

Download Job Interview Questions and Answers PDF

What is Linear-logarithm chasm?

Sort And Searching Interview Question
Sort And Searching Interview Question

Answer:

The alternative to using binary search is to guess 0, then 1, then 2, then 3, and so forth, until hitting the hidden number. We refer to such an algorithm as a brute-force algorithm: it seems to get the job done, but without much regard to the cost (which might prevent it from actually getting the job done for large problems). In this case, the running time of the brute-force algorithm is sensitive to the input value, but could be as much as N and has expected value N/2 if the input value is chosen at random. Meanwhile, binary search is guaranteed to use no more than lg N steps.

Download Sort And Searching Interview Questions And Answers PDF

Previous QuestionNext Question
Explain quick sort?Explain Binary representation?