Free Practice Quiz Question List

1 Algorithm Analysis and Big-O Notation Online Quiz Questions

Use this free practice quiz with 20 questions to review 1 Algorithm Analysis and Big-O Notation, test your knowledge, and prepare for your next test or exam.

20 questions
01
Fill in the blank
1 point

A stack removes items according to the rule.

02
True or false
1 point

An average-case complexity claim is meaningful only when the assumptions about the distribution of possible inputs are stated.

  1. A

    True

  2. B

    False

03
Choose all
1 point

Select all statements that correctly describe typical operation costs under the assumptions stated in the material.

  1. A

    Accessing an array element by index is typically Θ(1)\Theta(1).

  2. B

    Inserting near the beginning of an array can require Θ(n)\Theta(n) shifting.

  3. C

    Random access in a linked list is typically Θ(1)\Theta(1).

  4. D

    Search in a balanced search tree is typically Θ(log⁡n)\Theta(\log n).

  5. E

    Traversing a linked list to find a position is always Θ(1)\Theta(1).

04
Open ended
1 point

You are choosing between an array and a linked list. The workload requires frequent indexed reads in one case and frequent insertions at positions whose node pointers are already known in another case. Explain which representation is better for each workload and justify the choice using typical time complexities.

05
True or false
1 point

If an algorithm has runtime Θ(f(n))\Theta(f(n)), then it has both an O(f(n))O(f(n)) upper bound and an Ω(f(n))\Omega(f(n)) lower bound.

  1. A

    True

  2. B

    False

06
Choose one
1 point

Simplify the runtime expression 4n2+3n+94n^2+3n+9 using tight asymptotic notation.

  1. A

    Θ(1)\Theta(1)

  2. B

    Θ(n)\Theta(n)

  3. C

    Θ(n2)\Theta(n^2)

  4. D

    Θ(n3)\Theta(n^3)

07
Choose one
1 point

Which choice is an abstract data type rather than a concrete data structure?

  1. A

    A stack implemented with an array

  2. B

    The stack ADT specifying push, pop, and top

  3. C

    A linked list used to store stack nodes

  4. D

    A hash table used to implement lookup

08
Choose one
1 point

An algorithm has an outer loop that runs n times and, for every outer-loop iteration, an inner loop that also runs n times. What is the tight runtime complexity if the inner body takes constant time?

  1. A

    Θ(1)\Theta(1)

  2. B

    Θ(n)\Theta(n)

  3. C

    Θ(n2)\Theta(n^2)

  4. D

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

09
Choose one
1 point

A sequential search examines an unsorted array of n elements, and the target is guaranteed to be present at a uniformly random position. What is its average-case complexity?

  1. A

    Θ(n)\Theta(n) under the stated uniform assumption

  2. B

    Θ(1)\Theta(1) for every input

  3. C

    Θ(log⁡n)\Theta(\log n) because the target is eventually found

  4. D

    Θ(n2)\Theta(n^2) because every pair of elements is compared

10
Choose one
1 point

Under which condition is a hash table's expected search, insertion, and deletion time commonly Θ(1)\Theta(1)?

  1. A

    The table is sorted, so binary search always applies

  2. B

    The load factor is irrelevant to lookup time

  3. C

    Hashing guarantees Θ(1)\Theta(1) in every possible worst case

  4. D

    A suitable hash function and controlled load factor support expected Θ(1)\Theta(1) operations

11
Choose one
1 point

A recursive algorithm reaches a maximum recursion depth of n, and each call stores only a constant amount of information. What is its auxiliary space complexity due to the call stack?

  1. A

    Θ(1)\Theta(1), because each call stores only constant information

  2. B

    Θ(n)\Theta(n), because the recursion depth is n

  3. C

    Θ(log⁡n)\Theta(\log n), because every recursive algorithm halves its input

  4. D

    Θ(n2)\Theta(n^2), because the calls are nested

12
True or false
1 point

True or false: If an algorithm has tight runtime complexity Θ(n2)\Theta(n^2), then it is also correct to describe it as O(n3)O(n^3), although O(n2)O(n^2) is the tighter upper bound.

  1. A

    True

  2. B

    False

13
Written response
1 point

A divide-and-conquer algorithm satisfies T(n)=2T(n/2)+Θ(n)T(n)=2T(n/2)+\Theta(n). Enter its tight runtime complexity in LaTeX.

14
Written response
1 point

What term describes the additional memory an algorithm uses beyond the memory required to store its input?

15
Choose one
1 point

One part of an algorithm takes Θ(n)\Theta(n) time and a later part takes Θ(n2)\Theta(n^2) time. What is the tight complexity of the complete algorithm?

  1. A

    Θ(n)\Theta(n)

  2. B

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

  3. C

    Θ(n2)\Theta(n^2)

  4. D

    Θ(n3)\Theta(n^3)

16
Choose all
1 point

Select all statements that are supported by the stated data-structure complexity assumptions.

  1. A

    Search, insertion, and deletion in a balanced search tree are typically Θ(log⁡n)\Theta(\log n).

  2. B

    A hash table guarantees Θ(1)\Theta(1) search time in the worst case, regardless of collisions.

  3. C

    A hash table commonly has expected Θ(1)\Theta(1) operations with a suitable hash function and controlled load factor.

  4. D

    Direct random access in a linked list is typically Θ(1)\Theta(1).

17
Written response
1 point

A search procedure operates on a sorted array and discards half of the remaining elements after each comparison. What is its tight runtime complexity in terms of the array size nn?

18
Written response
1 point

An algorithm performs one constant-time operation for each bit in the binary representation of a positive integer xx. What is its runtime expressed as a tight asymptotic function of xx?

19
Fill in the blank
1 point

Complete the formal definition of an asymptotic upper bound: T(n)T(n) is O(f(n))O(f(n)) if there are positive constants and such that T(n)≤c⋅f(n)T(n) \le c \cdot f(n) for all n≥n0n \ge n_0.

20
Choose one
1 point

For sequential search in an array of nn elements, which pair correctly describes the best-case and worst-case runtimes?

  1. A

    Best case Θ(n)\Theta(n), worst case Θ(1)\Theta(1)

  2. B

    Best case Θ(1)\Theta(1), worst case Θ(n)\Theta(n)

  3. C

    Best case Θ(log⁡n)\Theta(\log n), worst case Θ(n)\Theta(n)

  4. D

    Best case Θ(1)\Theta(1), worst case Θ(log⁡n)\Theta(\log n)