Java Software Structures, 4th Edition Exercise Solutions, Ch. 2
Chapter 2 Exercise Solutions
EX 2.1. What is the order of the following growth functions?
a. 10n2 + 100n + 1000 O(n2)
EX 2.2. Arrange the growth functions of the previous exercise in ascending order of
efficiency for n = 10 and again for n = 1,000,000.
For n = 10:
Least efficient: 2n + 100n3
10n3 – 7
EX 2.3. Write the code necessary to find the largest element in an unsorted array of
integers. What is the time complexity of this algorithm?
int max;
if (intArray.length > 0)
{
max = intArray[0];