3) Let us define a function f(S) that returns the smallest 2 numbers of a set S and let N be the size of S
We form pairs of neighbouring positions in S ex. (1, 2); (3, 4); ... . If N is odd we keep position N by itself.
We proceed in doing [ N / 2 ] comparisons and finding the minimum of each pair. With this minimums we forms a second set S2. We call f(S2). The minimum in S is the minimum in S2 and the second minimum in S is the minimum between f(S2).second and pair( f(S2).first ). By pair(x) we denote the other element in the pair where we find x. For the example pair(2) = 1 and pair(3) = 4.
Let T(N) the number of comparisons for a set of N elements. It can be obtained by the reccurence T(N) = floor(N / 2) + T( floor((N+1) / 2) ) + 1. T(2) = 1; Solving the reccurence gives us T(N) = N + ceil(log2(N)) - 2 for any N >= 2.