An algorithm specifies the steps that transform an input into a result; a Java implementation must also respect numeric ranges, container access costs, and call-stack limits.
Count the whole operation
Binary search needs ordered input. Sorting an unsorted batch first is part of the cost. Recursion depth is not the same quantity as total work across all branches.
Common Mistakes
Test empty input, repeated values, boundary values, and an absent result. A correct output for one small fixture does not establish correctness for every valid input.
