This is how I was seeing the program. The program demonstrates a `binsearch` function which takes a input element (x) to search for, an array of integers and the length of the array as arguments.

The program determines the position of the element (x) by doing a binary search. ( How binary search is done can be explained a bit. Like, you are right that it works with sorted array only, and it finds a mid element compares and goes left or goes right, etc). 

Do you agree with the thought process?