Free Practice Quiz Question List

09. Evaluating Algorithm Efficiency Online Quiz Questions

Use this free practice quiz with 20 questions to review 09. Evaluating Algorithm Efficiency, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

When analyzing an algorithm that sorts a collection of records, what is the most appropriate interpretation of the input-size variable nn?

  1. A

    The number of processor cores available

  2. B

    The number of records being sorted

  3. C

    The numerical value of the largest record

  4. D

    The number of programming languages used

02
Choose one
1 point

A procedure performs one loop over nn items and then a second loop over nn items. What is its asymptotic time complexity?

  1. A

    O(1)O(1)

  2. B

    O(log⁡n)O(\log n)

  3. C

    O(n)O(n)

  4. D

    O(n2)O(n^2)

03
Choose one
1 point

Consider two nested loops where both the outer and inner loop execute exactly nn times. What is the asymptotic time complexity?

  1. A

    O(n)O(n)

  2. B

    O(log⁡n)O(\log n)

  3. C

    O(n2)O(n^2)

  4. D

    O(2n)O(2^n)

04
Choose all
1 point

Select all statements that correctly describe asymptotic notation.

  1. A

    Big-O describes an asymptotic upper bound.

  2. B

    Big-O automatically means worst-case analysis.

  3. C

    Big-Theta describes matching asymptotic upper and lower bounds.

  4. D

    Big-Theta retains all constant factors and lower-order terms.

05
Choose all
1 point

Select all correct statements about the best and worst cases of linear search through an array.

  1. A

    A target at the first position gives best-case O(1)O(1).

  2. B

    A target at the first position gives worst-case O(n)O(n).

  3. C

    A target at the last position gives best-case O(1)O(1).

  4. D

    A target at the last position or an absent target gives worst-case O(n)O(n).

06
True or false
1 point

True or false: Saying that an algorithm is O(n) automatically means that its worst-case running time is linear.

  1. A

    True

  2. B

    False

07
True or false
1 point

True or false: A loop that repeatedly replaces its remaining problem size with ⌊n/2⌋\lfloor n/2\rfloor has O(log⁡n)O(\log n) time complexity.

  1. A

    True

  2. B

    False

08
Written response
1 point

A loop runs from i=1i=1 through i=ni=n, inclusive. For n=1n=1, how many times does the loop body execute? Enter a whole-number count.

09
Fill in the blank
1 point

Complete the statements: The resource measure for computational work is , while the resource measure for memory use is .

10
Fill in the blank
1 point

Complete the statement: The dominant growth class of T(n)=4n2+7n+12T(n)=4n^2+7n+12 is .

11
Open ended
1 point

Analyze the following procedure, assuming AA contains nn values: it initializes sumsum to zero, scans every value xx in AA, adds xx to sumsum, and returns sumsum. State its asymptotic running time and its auxiliary space complexity, and explain the difference between the input array's space and auxiliary space.

12
Choose one
1 point

An algorithm executes an inner operation 1 time during the first outer iteration, 2 times during the second, and so on through nn times during the last. What is the tight asymptotic complexity?

  1. A

    Θ(n)\Theta(n)

  2. B

    Θ(n2)\Theta(n^2)

  3. C

    Θ(nlog⁡n)\Theta(n\log n)

  4. D

    Θ(2n)\Theta(2^n)

13
Choose one
1 point

An algorithm allocates a new array of length nn and copies the input array into it. What is the algorithm's auxiliary space complexity?

  1. A

    O(n)O(n)

  2. B

    O(1)O(1)

  3. C

    O(log⁡n)O(\log n)

  4. D

    O(n2)O(n^2)

14
Choose one
1 point

A duplicate-detection algorithm compares every pair of elements and returns only after all pairs have been checked when no duplicate exists. It uses two index variables and no additional array. Which classification is correct?

  1. A

    Worst-case time Θ(n)\Theta(n) and auxiliary space Θ(n)\Theta(n)

  2. B

    Worst-case time Θ(n2)\Theta(n^2) and auxiliary space Θ(n)\Theta(n)

  3. C

    Worst-case time Θ(n2)\Theta(n^2) and auxiliary space Θ(1)\Theta(1)

  4. D

    Worst-case time Θ(2n)\Theta(2^n) and auxiliary space Θ(1)\Theta(1)

15
Choose one
1 point

When analyzing an algorithm that receives a number written in binary, what should the input-size variable n represent?

  1. A

    The numerical value of the number

  2. B

    The number of bits used to represent the number

  3. C

    The number of arithmetic operations needed to read the number

  4. D

    The number of possible values of the number

16
Choose one
1 point

Consider this pseudocode: for i from 1 to n, execute an inner loop for j from 1 to i. What is the tight asymptotic running time?

  1. A

    Θ(1)

  2. B

    Θ(n)

  3. C

    Θ(n²)

  4. D

    Θ(log n)

17
True or false
1 point

True or false: An algorithm can be efficient or inefficient only after the underlying problem has been shown to be decidable.

  1. A

    True

  2. B

    False

18
Written response
1 point

An algorithm scans an array of n values and maintains only a fixed number of variables while it runs. What is the auxiliary-space complexity class?

19
Written response
1 point

A loop starts with n = 64 and repeatedly replaces n with floor(n / 2) while n > 1. How many iterations does it execute?

20
Written response
1 point

A simplified cost model assigns one unit to the initialization, one unit to each execution of the loop body, and one unit to the return statement. For the sum loop described in the material, with n = 8, what is the value of T(8)?