Variants of Binary Search (Using Recursive Approach)

Variants of Binary Search (Using Recursive Approach)

Binary search can be upgraded to the following five variants -

  • Index of a particular key
  • Index of the first occurrence of a key
  • Index of the last occurrence of a key
  • Index of least element greater than key
  • Index of greatest element less than key

image.png

Index of the first occurrence of a key

image.png

Index of the last occurrence of a key

image.png

Index of least element greater than key

image.png

Index of greatest element less than key

image.png

Conclusion

This is the end of the blog. Make sure to give a follow if you liked this.
Thanks💛