@Yasir: Yups...I also have the same algo...
Just to improvise your solution, you need not do binary search on both sides
of the pivot.
Just check End points (min-max) of the both sub-array to decide which side
to do a binary search..This works in the case of duplicate elements too.

for e.g.
2  5  8  12  45  78  91  100   101  104
k = 5
78  91  100   101  104  2  5  8  12  45
Pivot is at 2
You want to search for 12.
Check end points of both the sub-array (78,104 & 2,45)
Second range would contain 12.
So no need to call binSearch on first sub-array.

2  2  5  5  7
k = 3
So new arr is  5  7  2  2  5
Pivot is first occurrence of 2
You want to search for 5 (which is in both parts)
check end points to decide which sub-array to be searched.
While checking end-points itself you get the answer.

I hope you get it...

On Fri, Aug 12, 2011 at 11:37 PM, Yasir <yasir....@gmail.com> wrote:

> how abt  http://ideone.com/lN2og ??
>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/pZdvFb_t2b4J.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to