Professional Documents
Culture Documents
Answer:
Log n => 𝑛log n => n => 2^n => N^2 => N^3 => n!
Answer:
(i) is O(n^5)
(ii) is O(nlog(n^8))
Programming
3. (10 pts) Run/test program example 1 (slide 9). Understand loop structure and know how to
write and call a method (only screenshot of the output required)
4. (20 points) Write a main method to calculate the lowest grade among 100 random grades
(ranging 0-100) by modifying and calling the method in example 2 (slide 10) (submit code and
screenshot).
package example2;
import java.util.Random;
return lowest;
};
int Min=lowest(a,100);
System.out.println(Min);
}
}
5. (15 pts) Complete Search method in example 3 (slide 10) by adding the method header. Then
write a main method to test it (submit code and screenshot).
package example3;
import java.util.Random;
if (i < n)
return i;
else return -1;
};
//finding value 99
int findPos=Search(a,100,99);
System.out.println(findPos);
}
6. (25 points) Add a method into the class studentStatistics (slide 12) that finds the student who
has the highest score in an array of students. Print that student (name, ID, score). Test it in the
main method (submit code and screenshot page).
package studentstatistics;
return sum/n;
}
/*Add a method into the class studentStatistics (slide 12) that finds the student
who has the highest score in an array of students, Print that student (name, ID, score).*/
};
for(int i=0;i<3;i++)
arr[i]=new student();
Display(arr,3);
highest(arr,3);
}