Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do all parts of the question The program must be in Java To observe the importance of algorithm efficiency and the order of growth,

Please do all parts of the question

The program must be in Java

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions