Pivot in binary search

https://ide.codingblocks.com/#/s/28894 in this first i searched in right part and then in left part,tests failed
https://ide.codingblocks.com/#/s/28895 in thi first i searched in left part and then in right part,tests passed

how does these two make diffference is there anything like first we need to search in the left part or am i missing any logic please let me know

Actually both your codes have mistake in logic.
They don’t work in border case like
5
1 2 3 4 5
Think o it again. You need to make minor changes in code in the loop.
The second code passed the test cases as these corner cases may not have been included.
Try to correct it