Answered step by step
Verified Expert Solution
Question
1 Approved Answer
All codes must be in Java To observe the importance of algorithm efficiency and the order of growth, you are required to perform the following
All codes must be in Java
To observe the importance of algorithm efficiency and the order of growth, you are required to perform the following experiment. Assume an input of size 100,000 (denoted as N) (a) Linear function (O(N)): Write a function that loops over the input items (a single loop) and print the elapsed time taken by the function in milliseconds (b) Quadratic function (O(N2)): Write a function that loops over the input items with two-levels of nesting and print the elapsed time taken by the function in milliseconds. The function should have two nested loops (outer and inner) where each one starts from 0 to N (c) Cubicfunction (O(N3): Write a function that loops over the input items with three-levels of nesting and print the elapsed time taken by the function in milliseconds. The function should have three nested loops where each one starts from 0 to N Hint: The actual code inside the loop is not important. So make it simple and define a double variable in the beginning of your program, and then increment this variable inside the inner most loop (The example below is for two-level nesting). Double sum = 0; For (j=0, End Loop; j
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started