Knowledge check: Time complexity

Knowledge check: Time complexity

  1. Which has the largest time to compute?

    • O(1)

    • O(N)

    • O(log n)

  2. Given the following lines of code pseudocode;

     N = 7 
    
     FOR i = 1 TO N:
    
           output(i)
    
    • O(N)

    • O(n^2)

    • O(1)

  3. Given the following lines of code pseudocode;

     N = 7 
    
     FOR i = 1 TO N:
    
           FOR j = 1 TO N:
    
              output(N)
    
    • O(n^2)

    • O(1)

    • O(N)

  4. Given the following lines of code pseudocode:

     N = 37 
    
     FOR i = 1 TO N:
    
           j = 1
    
           WHILE j < 10:
    
              output(j*N)
    
              j = j + 1
    
    • O(n^2)

    • O(N)

    • O(1)

  5. Given the following lines of code pseudocode:

     N = 10 
    
     FOR i = 1 TO 5:
    
             FOR j = 1 TO i:
    
                     output(i*j)
    
    • O(n^2)

    • O(1)

    • O(Log N)

  6. Given the following lines of code pseudocode: output(N)

     N = 7 
    
     FOR i = 1 TO N:
    
                FOR j = 1 TO N:
    
                     output(N)
    
    • O(1)

    • O(N)

    • O(n^2)