binary_search for sorted array
pseudo code for work count