If middle element is different of the arrays , it means that the index we are searching for is either mid , or before mid . Hence we update right to mid - 1.
else { $ index = $ mid ; $ right = $ mid - 1 ; } }