What is the running time of the following code public static

What is the running time of the following code? public static List makeList(int N) {ArrayList lst = new ArrayList(); for(inti = 0; i

Solution

Answer:

The running time of this code is O(N).

Since the code has a one for loop which runs from 1 to N. Thus it takes total time of N to finish its execution.

 What is the running time of the following code? public static List makeList(int N) {ArrayList lst = new ArrayList(); for(inti = 0; i SolutionAnswer: The runnin

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site