Implement a function to perform a binary search on a sorted array.

Instruction: Write a function that performs a binary search on a sorted array and returns the index of the element if found, otherwise -1.

Context: This question assesses the candidate's algorithm skills and their ability to implement efficient search algorithms.

Upgrade to view answer

Related Questions