I'm using binary search to locate a record. My question is not about whether the data is present or not. I'll list my questions below.
- if data are in following order
1 2 3 4 4 5 5 5 6 7 8 8 9 10 11
If now i want to search 5 where it is locate first. By using binary search algorithm I can get the 5 is present or not. in the above case i can get the 6th location of 5( totally 13 data) . But I need to get 5th location. How can i get this using binary search ? Once again in some cases i need to get last position of the given data. How can i get this binary search algorithm.
Is there any fastest method than binary search ? Not but hashing method ?