1)

The key to solving this problem is computing the maximum size set of
inputs L such that for any two inputs in L there is a different answer
for the minimum and/or maximum value.  A good way to represent the
answer here is the index of the array where the max element is located
and the index of the array where the min element is located.  There
are n possibilities for the index of the array where the maximum
value occurs.  Then there are n-1 possibilities for which of the
remaining elements holds the minimum value.  For each of these
n(n-1) inputs, the answer is different because pairwise they either
have a differnt min, a different max, or both the min and max are
different.  

Since a decision tree of height h has at most 2^h leaves, it follows
that h must be large enough so that 2^h >= n(n-1).  Taking base-2
logarithms of both sides yields we must have h >= log_2 n(n-1) = log_2
n + log_2 (n-1) >= 2 log_2 (n-1).

Hence any comparison-based algorithm for this problem must make at least
2 log_2 (n-1) comparisons and hence has time complexity at least 2 log_2 (n-1).






















































2)

The key to solving this problem is computing how many different possible
solutions there are for which elements are less than x.  Remember that
A is a sorted array and thus the inputs must be consistent with an
array that is sorted.  Namely, if A[i] < x then A[0]....A[i-1] must
also be < x.  As an easy representation, I'll put 1 under the array
element if it is < x and 0 if it is >= x.  Then the following represents
the inputs that can occur that all have distinct answers.

A[0] A[1] A[2] .... A[n-2] A[n-1]    In English
---------------------------------    ----------
 1    1     1         1      1        all elements < x
 1    1     1         1      0        first n-1 elements < x
 1    1     1         0      0        first n-2 elements < x
.
.
.
 1    1     0         0      0        first 2 elements < x
 1    0     0         0      0        first element < x
 0    0     0         0      0        no elements < x

It should be clear that an input can created to correspond to each
of the above and each have different answers.  Notice that
in general there are n+1 rows above.  Thus any decision tree for
solving this problem must have at least n+1 leaves.

Since a decision tree of height h has at most 2^h leaves, it follows
that h must be large enough so that 2^h >= n+1.  Taking base-2
logarithms of both sides yields we must have h >= log_2 n+1.

Hence any comparison-based algorithm for this problem must make at least
log_2 (n+1) comparisons and hence has time complexity at least log_2 (n+1).

NOTE: I would not include this solution if you could just submit
it for problem 3a.  So think about how the array no longer being sorted
changes things.




































3)

The key to solving this problem is computing how many different inputs
there are such that pairwise they have different answers for the given
problem.  We do this by counting all the possiblities for
how the 2 elements are merged into the n elements.  There are n+1 slots
(before the first element of A, after the first element of A, ...., after
the last element of A).  Hence there are C(n+1,2) = n(n+1)/2 ways in which
the two elements fall in different slots (their orderis fixed since they
were sorted) and n+1 ways in which they fall into the same slot.  Hence
by the sum rule, there are n(n+1)/2 + (n+1) = (n+1)(n+2)/2 possibilities.
Hence there must be at least (n+1)(n+2)/2 leaves.

Since a decision tree of height h has at most 2^h leaves, it follows
that h must be large enough so that 2^h >= (n+1)(n+2)/2.  Taking
base-2 logarithms of both sides yields we must have

    h >= log_2 (n+1)(n+2)/2 = log_2 (n+1) + log_2 (n+2) -1 >= 2 log_2 (n+1) - 1.

Hence any comparison-based algorithm for this problem must make at least
2 log_2 (n+1) - 1 comparisons and hence have time complexity >= 2 log_2 (n+1) - 1.






















































4)

First consider when there is 1 base-10 digits per radix sort digit.  Then each
social security number is a 9 digit number where each number is between 0 and 9
(i.e. a base 10 number).   So each of the 9 passes of counting sort will have
time complexity

    5 (100,000) + 4 (10) = 500,040   

and hence the total time is  9 * 500,040 = 4,500,360

Next consider when there are 3 base-10 digits per radix sort digit.  Then each
social security number is a 3 digit number where each number is between 0 and 999
(hence you are representing the social security number in base 10^3 = 1000).
So each of the 3 passes of counting sort will have time complexity

    5 (100,000) + 4 (1000) = 504,000   

and hence the total time is  3 * 504,000 = 1,512,000

Now consider when there are is one radix digit consisting of 4 base-10 digits
and the other radix digit consisting of 5 base-10 digits.  Hence the time complexity
for the counting sort pass on the radix digit that groups 4 base-10 digits is:

   5 (100,000) + 4 (10^4) = 540,000

And the time complexity for the pass on the radix digit that groups 5 base-10 digits is:

   5 (100,000) + 4 (10^5) = 900,000

Hence the total time is 540,000 + 900,000 = 1,440,000


So the last option is the best.