send the data set to the hash table
now search for a[i]+x in the table if found for 'k' den a[k] and a[k]+x is
the required pair

complexity:
o(n)(for mapping)+O(n)(for search a[i]+x)=O(n)

@Snehal can i see your solution please.

On Thu, Dec 23, 2010 at 12:11 AM, Aviral Gupta <[email protected]> wrote:

> use hash map.....O(n)
> or you can use use the binary search for each element
> O(nlogn) ........
>
> Regards
> Aviral
> http://coders-stop.blogspot.com
>
> On Dec 22, 3:05 pm, snehal jain <[email protected]> wrote:
> > How will you find the pair from an sorted array whose difference is x
>
> --
> 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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
bhupendra dubey

-- 
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.

Reply via email to