Write the code necessary to find the largest element in an unsorted array of integers. What is the time complexity of this algorithm?
Q1. Write the code necessary to find the largest element in an unsorted array of integers. What is the time complexity of this
Q2. Determine the growth function and order of the following code fragment:
for (int count=0; count < n; count++)
{
for (int count2=0; count2 < n; count2=count2+2)
{
System.out.println(count, count2);
}
}
Q3. Determine the growth function and order of the following code fragment:
for (int count=0; count < n; count++)
{
for (int count2=0; count2 < n; count2=count2*2)
{
System.out.println(count, count2);
}
}
Q4. What is the order of the following growth functions?
- 10n2 + 100n + 1000
- 10n3 – 7
- 2n + 100n3
- n2 log n
Q5. Arrange the growth functions of Q4 in ascending order of efficiency for n=10 and again for n = 1,000,000.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images