So then indeed we have a polynomial time algorithm.  
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: "Tanna, Nisarg" <[email protected]>

Date: Thu, 30 Apr 2009 08:58:11 
To: <[email protected]>
Subject: [algogeeks] find k-th smallest element in the set of combined m+n 
 elements


Hi Saurabh,

Here are the steps:

Assume arrays A[n] and B[m]

- x = A[k]
- Look for value (x-1) in array B. Binary search will take O(logm) time.
- If no such value is present then return x
- If such a value is present at index l, then return (A[k-l] > B[l]? A[k-l]
: B[l])

As you can see there is only 1 binary search performed. Rest is the constant
time operation.




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

Reply via email to