Capabilities of Binary Search Algorithm: Part-2

More than just a Searching Algorithm

Let’s recapitulate what all we have covered —

So last weekend, I released the first part of the article, “Capabilities of Binary Search Algorithm: Part-1” in which I introduced you with the famous searching algorithm known as Binary Search Algorithm. We also discussed how it mas be modified a little bit to do many things other than just searching.

  • Searching in Reversed Sorted Array.
  • Finding First and Last Occurance an Element.
  • Finding Floor and Ceil of an Element.
  • Finding the peak of an array.
  • Finding Square Root of a number.
  • Number of times a Sorted array is rotated.
  • Searching in Nearly Sorted Array.
  • Finding a position on an Element in an infinite array.
  • Searching in Bitonic Infinite Array.
  • Searching in 2-D Array.

5. Finding Square Root of a number.

Here we’ll be finding power and square root of a number using Binary Search Algorithm.

6. Number of times a Sorted array is rotated.

In this problem, you’ll be provided with an unsorted array and you need to count how many times a Sorted array is rotated.

7. Searching in Nearly Sorted Array.

Here you’ll be provided with a nearly sorted array with shuffling up to 2 elements. You need to search element at an index in this suffered array. Here is an example:-

8. Finding a position on an Element in an infinite array

In this question, you are given an infinite array and you are expected to search an element in the same.

9. Searching in Bitonic infinite Array.

A Bitonic array is an array which only contains 0’s and 1’s. You are provided with an infinite array which contains only 0’s and 1’s. You need to find first Occurance of 1 in this array.

10. Searching in 2-D Array

Search An element in 2-D Matrix

Conclusion

We did it! If you followed along with me through this whole tutorial, you should have a really good feel for Binary Search now. To summarize, we have divided the article into two parts. The first part deal with the Explanation of Binary Search Algorithm and few hidden Capabilities of the same. The second part(this article) covers rest of the Hiddent Capabilies and variations of Binary Search Algorithm.

--

--

JP Morgan Chase & Co | Google DSC LEAD | Microsoft Student Partner | Web developer | Technical Writer | TheProgrammedEnthusiast |

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Srivastava

JP Morgan Chase & Co | Google DSC LEAD | Microsoft Student Partner | Web developer | Technical Writer | TheProgrammedEnthusiast |