For example I have an sorted array.
array[0]=1
array[1]=3
array[2]=2
array[3]=2
array[4]=4
First,
I use binary search to find an item. I found array[2]. I want to find duplicate item from the array, so I check the next index, if the value of next index doesn't match with array[2], it mean no duplicate item found. Am in right way to find duplicate item?
No that is not shure. if You are looking for "2" you might find array[2] or array[3]!
so you have to check the previous
and the next index(s).
Greetings
K-H