Question: I was given this time complexity assignment for my computer science class and I mostly understand how to calculate the time complexity but these two
I was given this time complexity assignment for my computer science class and I mostly understand how to calculate the time complexity but these two I am just a little confused on. I know the first for loop for question E) would be O(N) and the second I know runs 1 less time every iteration so I guess that would be n-1 but I am really not sure. Question F) I think it's N^3 since you have N*N in the second loop which is N^2 then times N again gives you N^3 but once again I am not entirely sure, so a good explanation on how time complexity would work would be awesome!
E) for (int x=0; x < n; x++)
for (int y=x; y < n; y++)
System.out.print(*);
(F) for (int x=0; x < n; x++)
for (int y=0; y < n * n; y++)
System.out.print(*);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
