0

Linear time deterministic algorithm exists for selection. I read this link and the recurrence for a divide and conquer approach looks like: T(n) <= 12n/5 + T(n/5) + T(7n/10)

However, I don't understand why must it be T(7n/10). The link itself has mentioned that each half of the partition has size (3n/10), so the algorithm recurses on (6n/10). Even if we include the 5 elements from the group of the median of medians, the recursion is on (6n/10+5). I do understand that 7n/10 is a valid upper bound on the size of the recursion, but isn't it too weak an upper bound here?

1 Answers1

0

The 7n/10 is not the result of 3n/10 + 3n/10 + n/10; it comes from doing n - 3n/10.

From the link:

It's easier to talk about this in terms of the elements thrown away (not included in the call).

The argument is that the recursive call is made on a shorter list formed by not including some elements. By showing that at least 3n/10 elements are excluded from the list, it follows that at most 7n/10 elements are included, and that bound is tight because the 3n/10 bound is tight.

So, it's shown that L1 and L3 both have size at least 3n/10 by showing that they each contain at least 3 elements from each of n/10 subsets; then one of L1 or L3 is excluded from the recursive call, giving the result. Since only one of L1 or L3 is excluded - not both - it would not make sense to add their sizes together.

kaya3
  • 47,440
  • 4
  • 68
  • 97