This is very good and sharp Mathematics.

---
Martin Michael Musatov
Reformed [P=NP Winder]
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Nick <[email protected]>

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



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.


On Apr 30, 3:27 am, Saurabh <[email protected]> wrote:
> Two sorted sequences of size m and n are given. Write an efficient
> algo to find k-th smallest element in the set of combined m+n
> elements. Note that the best possible algorithm runs in O(log(max
> (m,n))).



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