Which statement best describes an abstract data type (ADT)?
01 Algorithm Analysis and Big-O Notation Online Quiz Questions
Use this free practice quiz with 20 questions to review 01 Algorithm Analysis and Big-O Notation, test your knowledge, and prepare for your next test or exam.
Which three proof obligations are essential parts of a loop-invariant argument? Select all correct choices.
- A
Initialization
- B
Randomized testing
- C
Maintenance
- D
Termination
True or false: The input-size variable n always means the number of elements in an array, regardless of the problem being analyzed.
- A
True
- B
False
A stack uses which access discipline?
- A
FIFO
- B
LIFO
- C
Priority order
- D
Sorted order
In a correctness argument, the states what must be true before execution, and the states what is guaranteed after execution.
Which two statements correctly compare worst-case and average-case analysis? Select all correct choices.
- A
Worst-case analysis provides a guarantee for every input of a given size.
- B
Average-case analysis is meaningful without any probability distribution.
- C
Worst-case analysis always gives the exact elapsed time in seconds.
- D
Average-case analysis uses an expected cost under a specified distribution.
Big-O gives an asymptotic , Big-Omega gives an asymptotic , and Big-Theta gives an asymptotically .
True or false: Binary search has logarithmic running time on any collection, even if the collection is unsorted or does not support efficient access to its middle element.
- A
True
- B
False
Analyze a merge-sort-style algorithm that recursively sorts two subarrays of size n/2 and then merges the results in linear time. Write its recurrence and give a tight asymptotic bound for its running time.
A program executes one loop taking Θ(n) time followed by a separate loop taking Θ(n²) time. What is the total asymptotic running time?
- A
Θ(n)
- B
Θ(n²)
- C
Θ(n³)
- D
Θ(log n)
Which statement best distinguishes an abstract data type from its implementation?
- A
An ADT specifies internal memory layout, while an implementation specifies only the allowed operations.
- B
An ADT specifies supported values and operations, while an implementation specifies how those operations are realized.
- C
An ADT guarantees a particular asymptotic complexity, while an implementation guarantees correctness.
- D
An ADT is used only for recursive algorithms, while an implementation is used only for iterative algorithms.
True or false: If an algorithm runs in Θ(n), then it is also technically O(n2).
- A
True
- B
False
What term names a condition that must remain true about a data structure's internal state throughout its operations?
Consider the loop: set i=1; while i<n, perform constant-time work and set i=2i. What is its tight running time?
- A
Θ(n)
- B
Θ(logn)
- C
Θ(n2)
- D
Θ(1)
An outer loop runs for i=1 through n, and on iteration i an inner loop performs constant-time work exactly i times. What is the tight running time?
- A
Θ(n)
- B
Θ(n2)
- C
Θ(nlogn)
- D
Θ(2n)
Which complexity statement correctly describes hash-table lookup under the conditions discussed in the material?
- A
It is always Θ(1), regardless of collisions.
- B
It is always Θ(logn), because hashing keeps keys ordered.
- C
It is O(1) on average but can be O(n) in the worst case.
- D
It is O(nlogn) on average because every key must be sorted.
A recursive search has running time T(n)=T(n/2)+Θ(1). What is its tight asymptotic running time?
What auxiliary stack-space bounds can a recursive traversal have for a balanced binary tree versus a highly unbalanced binary tree, each containing n nodes?
- A
Both cases use Θ(1) stack space because each node is processed once.
- B
A balanced tree uses O(logn) stack space, while a highly unbalanced tree can use O(n).
- C
A balanced tree uses O(n) stack space, while a highly unbalanced tree uses O(logn).
- D
Both cases use O(nlogn) stack space because traversal visits all nodes.
A data structure has occasional expensive operations, but the average cost per operation over a long sequence remains small. What standard analysis term describes this average cost over the sequence?
An algorithm receives an input array and creates one temporary auxiliary array containing 100 elements. Each temporary element occupies 8 bytes. Ignoring any constant-size variables, how many bytes of auxiliary space does the temporary array require?