another method is........... firstly use binary search(once) for finding that x exist in left or right part of array now use bst in each node store the value and no. of times it appeared..now start inserting the node..at the end u will get bst with no repitition.... now search for x for this do inorder traversal and u will get from which index(n/2+index value of that node) to which index that number lies... space complexity <O(n)........//because elements r repetead time complexity < O(nlogn)
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
