its simple. binary search for index of first and last occurence and return its difference
On Sun, Jun 19, 2011 at 12:04 PM, aanchal goyal <[email protected]>wrote: > given a sorted array, how to find number of occurences of a number x in it > in O(logn)? > > -- > Regards,* > Aanchal Goyal*. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Harshal Choudhary, Final Year B.Tech CSE, NIT Surathkal, Karnataka, India. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
