3.10. Discussion QuestionsΒΆ

  1. Give the Big-O performance of the following code fragment:

    for i in range(n):
       for j in range(n):
          k = 2 + 2
    
  2. Give the Big-O performance of the following code fragment:

    for i in range(n):
         k = 2 + 2
    
  3. Give the Big-O performance of the following code fragment:

    i = n
    while i > 0:
       k = 2 + 2
       i = i // 2
    
  4. Give the Big-O performance of the following code fragment:

    for i in range(n):
       for j in range(n):
          for k in range(n):
             k = 2 + 2
    
  5. Give the Big-O performance of the following code fragment:

    for i in range(n):
       k = 2 + 2
    for j in range(n):
       k = 2 + 2
    for k in range(n):
       k = 2 + 2
    
You have attempted of activities on this page