For unlimited access to Homework Help, a Homework+ subscription is required.
11. How many times does the letter K get printed in the following code? for (int i = 0; i < 5; i++) System.out.println("K"); for (int j = 0; j
14. How many times does the word "hello" get printed when the following snippet of code is executed? int i = 0; while (i < 10) { int j = 0; while (j < 5) { System.out.println("hello"); j++; i++;
Question 11. [5 MARKS] Each code fragment in the table below operates on list L, which has length k where k is very large - at least in the tens of thousands. For each fragment, give an expression in terms of k for how many times happy! is printed, and circle whether the behaviour is constant, linear, quadratic or something else. Code How many times is happy! printed? Complexity (circle one) for i in range (len (L)): print('happy!') for item in L: print('happy!') constant linear quadratic something else for i in range (len(L)) for item in L[:i]: print('happy!' constant linear quadratic something else # Precondition: len(L) % 10 == 0 i = 0 while i < len(L): print("happy!') i = i + len(L) // 10 constant linear quadratic something else for item in L[1000:2000] : print('happy!' constant linear quadratic something else for item in L[10:] : print('happy!' constant linear quadratic something else