Unit 1: Introduction - Practice Quiz

ECAP538 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which principle describes how elements are removed from a stack?

Elementary data structures Easy
A. Last In, First Out
B. Largest Value First
C. First In, First Out
D. Smallest Value First

2 Which principle is normally followed by a queue?

Elementary data structures Easy
A. Random In, Random Out
B. Middle In, First Out
C. Last In, First Out
D. First In, First Out

3 Which data structure stores elements that are commonly accessed using an index?

Elementary data structures Easy
A. Queue
B. Stack
C. Array
D. Graph

4 In the basic Random Access Machine model, how are simple operations usually treated?

Basic computational models Easy
A. As taking logarithmic time
B. As taking quadratic time
C. As taking constant time
D. As taking linear time

5 What is the main purpose of a computational model in algorithm analysis?

Basic computational models Easy
A. To design user interfaces
B. To define operation costs
C. To choose variable names
D. To format program output

6 What does commonly represent when analysing an algorithm?

Basic computational models Easy
A. The value of one instruction
B. The size of the input
C. The name of the algorithm
D. The number of processors

7 What does the best-case running time describe?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Easy
A. The expected time across inputs of size
B. The maximum time for an input of size
C. The minimum time for an input of size
D. The fixed time for every input of size

8 What does the worst-case running time describe?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Easy
A. The maximum number of operations
B. The minimum number of operations
C. The exact number of operations
D. The average number of operations

9 What does average-case analysis estimate?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Easy
A. The shortest running time
B. The longest running time
C. The compilation running time
D. The expected running time

10 What is the worst-case number of element comparisons in a linear search through elements?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Easy
A.
B.
C.
D.

11 What does big notation commonly express?

Asymptotic notations: big O notation Easy
A. An exact instruction count
B. An input probability value
C. An asymptotic upper bound
D. An asymptotic lower bound

12 Which complexity represents linear growth?

Asymptotic notations: big O notation Easy
A.
B.
C.
D.

13 Which notation represents constant-time complexity?

Asymptotic notations: big O notation Easy
A.
B.
C.
D.

14 What is the big complexity of ?

Asymptotic notations: big O notation Easy
A.
B.
C.
D.

15 What is recursion?

Recursion Easy
A. An array sorting its elements
B. A variable changing its type
C. A loop running without conditions
D. A function calling itself

16 What is the purpose of a base case in recursion?

Recursion Easy
A. To increase the input size
B. To remove the return value
C. To repeat the recursive call
D. To stop the recursive calls

17 Which formula correctly defines factorial recursively for ?

Recursion Easy
A.
B.
C.
D.

18 What does a recurrence relation describe in recursive algorithm analysis?

Recurrence relations to analyse recursive algorithms Easy
A. Syntax using language keywords
B. Output using random variables
C. Running time using smaller inputs
D. Memory using unrelated programs

19 What is the asymptotic solution of with ?

Recurrence relations to analyse recursive algorithms Easy
A.
B.
C.
D.

20 What is the asymptotic solution of with ?

Recurrence relations to analyse recursive algorithms Easy
A.
B.
C.
D.

21 A queue initially contains , with at the front. After performing dequeue, enqueue(40), and enqueue(50), what is the queue from front to rear?

Elementary data structures Medium
A.
B.
C.
D.

22 Which data structure is most appropriate for processing nested function calls in the order required for returns?

Elementary data structures Medium
A. A hash table
B. A linked list that always removes its oldest element first
C. A queue
D. A stack

23 A graph has vertices and edges, where is much smaller than . Which representation generally uses less space?

Elementary data structures Medium
A. A table that stores every absent edge along with every present edge
B. A stack containing all possible vertex pairs
C. An adjacency matrix using space
D. An adjacency list using space

24 A binary search tree contains the keys inserted in that order. Which key is the left child of ?

Elementary data structures Medium
A.
B.
C.
D.

25 In the unit-cost RAM model, an algorithm executes primitive operations. What running time is assigned to it asymptotically?

Basic computational models Medium
A.
B. because each individual RAM instruction has constant cost
C.
D.

26 In the comparison model, a comparison-based sorting algorithm is represented by a binary decision tree. What does each leaf represent?

Basic computational models Medium
A. The memory location of an input key
B. A single comparison between two keys
C. The complete sequence of machine instructions used by every execution
D. A possible ordering of the input

27 Why can treating arithmetic on arbitrarily large integers as a constant-time operation produce a misleading analysis?

Basic computational models Medium
A. Integer operations are unsupported by the RAM model
B. The cost can depend on the number of bits
C. The cost is determined only by how many variables the algorithm declares
D. Every arithmetic operation requires recursive code

28 For linear search on an array of distinct elements, which situation gives the best-case running time?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Medium
A. The target occurs after exactly half of the array has been examined
B. The target is the final element
C. The target is the first element
D. The target is absent from the array

29 Suppose a successful linear search is equally likely to target any of the array positions. What is the expected number of comparisons?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Medium
A.
B.
C.
D.

30 Quicksort always chooses the first element as its pivot. Which input is most likely to produce its worst-case behaviour?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Medium
A. An already sorted array
B. A randomly shuffled array
C. An array whose first value happens to equal the median on every recursive call
D. An array split into equal unsorted halves

31 An algorithm takes operations with probability and operations with probability . What is its expected operation count?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Medium
A.
B.
C.
D.

32 What is the tightest big O bound among the choices for ?

Asymptotic notations: big O notation Medium
A.
B.
C.
D.

33 Consider a loop where starts at and is doubled after each iteration until . What is the loop's running time?

Asymptotic notations: big O notation Medium
A. because multiplication by two is itself a constant-time operation
B.
C.
D.

34 An outer loop runs times, while an inner loop runs from through the current outer-loop index . What is the total running time?

Asymptotic notations: big O notation Medium
A.
B.
C.
D.

35 What value is returned by the following function when called as ? and for .

Recursion Medium
A.
B.
C.
D.

36 A recursive function reduces its argument from to and performs constant work per call. What is its maximum call-stack depth?

Recursion Medium
A.
B.
C. because every active call stores all results from earlier calls
D.

37 Which change is necessary to prevent infinite recursion in a function that repeatedly calls itself with a smaller positive integer?

Recursion Medium
A. Add a reachable base case
B. Increase the argument before every recursive call so that it eventually overflows
C. Use two recursive calls
D. Store the argument in a queue

38 What is the asymptotic solution of with ?

Recurrence relations to analyse recursive algorithms Medium
A.
B.
C.
D.

39 What is the asymptotic solution of with ?

Recurrence relations to analyse recursive algorithms Medium
A.
B. because the recurrence contains a recursive term for every smaller input
C.
D.

40 What is the asymptotic solution of with ?

Recurrence relations to analyse recursive algorithms Medium
A.
B.
C.
D.

41 A dynamic array starts empty with capacity . Whenever an append finds the array full, its capacity is doubled and all existing elements are copied before the new element is inserted. If , how many existing-element copies occur during the first appends?

Elementary data structures Hard
A.
B.
C.
D.

42 A queue is implemented using input and output stacks. Enqueue pushes onto the input stack; dequeue transfers every item to the output stack only when the output stack is empty. For any sequence of operations starting from empty, which bounds are tight?

Elementary data structures Hard
A. Worst-case ; amortized
B. Worst-case ; amortized
C. Worst-case ; amortized
D. Worst-case ; amortized

43 A disjoint-set forest uses both union by rank and path compression. For operations, including Make-Set operations, which asymptotic bound applies to the total running time?

Elementary data structures Hard
A.
B.
C.
D.

44 Which capability is available in a word-RAM with -bit words but not generally in a pure pointer-machine model?

Basic computational models Hard
A. Accessing array cell from an integer index
B. Updating a constant number of pointer fields
C. Comparing two stored keys in constant time
D. Following a stored pointer in constant time

45 An algorithm computes using multiplications. Why does the claim that its running time is fail in the bit-complexity model?

Basic computational models Hard
A. Factorial cannot be represented exactly
B. Multiplication cost grows with operand length
C. The algorithm requires comparison sorting
D. The number of recursive calls is exponential

46 In the deterministic comparison-tree model, an algorithm sorts distinct keys. What lower bound follows directly from the number of possible input orders?

Basic computational models Hard
A. At least comparisons on every input
B. At least comparisons in the worst case
C. At least comparisons in the worst case
D. At least comparisons in the worst case

47 A binary string of length is selected uniformly from all nonzero strings. An algorithm scans left to right and stops at the first . What is the exact expected number of inspected bits?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Hard
A.
B.
C.
D.

48 Randomized Quicksort chooses its pivot uniformly from the current subarray. For any fixed input containing distinct keys, which statement correctly distinguishes expected and worst-randomness behavior?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Hard
A. Expected ; worst choices
B. Expected ; worst choices
C. Expected ; worst choices
D. Expected ; worst choices

49 An algorithm has best-case running time and worst-case running time . Without specifying an input distribution, what can be concluded about its average-case time?

Analysis of algorithms: best-case, average-case, and worst-case behaviour Hard
A. It must be
B. It must be
C. It lies between and
D. It cannot have any asymptotic bound

50 For integers , let . Which statement is true?

Asymptotic notations: big O notation Hard
A.
B.
C.
D.

51 Let . Which asymptotic classification is correct for every fixed and ?

Asymptotic notations: big O notation Hard
A. and
B. and
C. and
D. and

52 Define when is prime and otherwise. Which relation between and is correct?

Asymptotic notations: big O notation Hard
A. and
B.
C. but
D. but

53 Quicksort is modified to recurse only on the smaller partition and to process the larger partition by iteration. What are the tight worst-case time and auxiliary-stack bounds?

Recursion Hard
A. time and stack
B. time and stack
C. time and stack
D. time and stack

54 A top-down recursive Fibonacci algorithm evaluates and memoizes every computed value. Including the memo table and recursion stack, what are its tight time and space bounds?

Recursion Hard
A. time and space
B. time and space
C. time and space
D. time and space

55 Consider a recursive procedure that makes two separate calls on and performs local work, without memoization. What is its total running time?

Recursion Hard
A.
B.
C.
D.

56 For powers of two, solve with .

Recurrence relations to analyse recursive algorithms Hard
A.
B.
C.
D.

57 Assume constant base-case cost. What is the solution of ?

Recurrence relations to analyse recursive algorithms Hard
A.
B.
C.
D.

58 For powers of two and constant base-case cost, solve for .

Recurrence relations to analyse recursive algorithms Hard
A.
B.
C.
D.

59 Given and , which bound is tight?

Recurrence relations to analyse recursive algorithms Hard
A.
B.
C.
D.

60 For sufficiently large , let with a constant-size base case. What is the tight solution?

Recurrence relations to analyse recursive algorithms Hard
A.
B.
C.
D.