Answer:
Explanation:
dimensions or calculation
Answer:
boolean isEven = false;
if (x.length % 2 == 0)
isEven = true;
Comparable currentMax;
int currentMaxIndex;
for (int i = x.length - 1; i >= 1; i--)
{
currentMax = x[i];
currentMaxIndex = i;
for (int j = i - 1; j >= 0; j--)
{
if (((Comparable)currentMax).compareTo(x[j]) < 0)
{
currentMax = x[j];
currentMaxIndex = j;
}
}
x[currentMaxIndex] = x[i];
x[i] = currentMax;
}
Comparable a = null;
Comparable b = null;
if (isEven == true)
{
a = x[x.length/2];
b = x[(x.length/2) - 1];
if ((a).compareTo(b) > 0)
m = a;
else
m = b;
}
else
m = x[x.length/2];
The recursive function would work like this: the n-th odd number is 2n-1. With each iteration, we return the sum of 2n-1 and the sum of the first n-1 odd numbers. The break case is when we have the sum of the first odd number, which is 1, and we return 1.
int recursiveOddSum(int n) {
if(2n-1==1) return 1;
return (2n-1) + recursiveOddSum(n-1);
}
To prove the correctness of this algorithm by induction, we start from the base case as usual:

by definition of the break case, and 1 is indeed the sum of the first odd number (it is a degenerate sum of only one term).
Now we can assume that
returns indeed the sum of the first n-1 odd numbers, and we have to proof that
returns the sum of the first n odd numbers. By the recursive logic, we have

and by induction,
is the sum of the first n-1 odd numbers, and 2n-1 is the n-th odd number. So,
is the sum of the first n odd numbers, as required:

Answer:
A foundation plays three major roles in the construction of a structure. A good and strong foundation keeps the building standing while the forces of nature wreak havoc. Well-built foundations keep the occupants of the building safe during calamities such as earthquake, floods, strong winds etc.