Cse408 Unit 6
Cse408 Unit 6
Complexity Classes
1. Which of the following complexity classes represents the set of decision problems that
can be solved by a deterministic Turing machine in polynomial time? a) P b) NP c) NP-
hard d) NP-complete Answer: a) P
2. The Euclidean algorithm is used to find the: a) Greatest Common Divisor (GCD) of two
numbers b) Least Common Multiple (LCM) of two numbers c) Prime factorization of a
number d) Modular inverse of a number Answer: a) Greatest Common Divisor (GCD) of
two numbers
3. Which of the following is NOT a property of prime numbers? a) Prime numbers are
divisible by 1 and themselves. b) Prime numbers have exactly two distinct positive
divisors. c) Prime numbers are always odd. d) Prime numbers cannot be expressed as a
product of two smaller numbers. Answer: c) Prime numbers are always odd.
4. The time complexity of the Sieve of Eratosthenes algorithm for finding prime numbers up
to a given limit is: a) O(n) b) O(n log n) c) O(n^2) d) O(sqrt(n)) Answer: d) O(sqrt(n))
5. Which of the following is an example of a number-theoretic algorithm? a) QuickSort b)
Dijkstra's algorithm c) Prim's algorithm d) Miller-Rabin primality test Answer: d) Miller-
Rabin primality test
6. The complexity class co-NP represents the set of decision problems for which: a) There
exists a non-deterministic Turing machine that can solve them in polynomial time. b)
There exists a deterministic Turing machine that can solve them in polynomial time. c)
There exists a non-deterministic Turing machine that can verify their solutions in
polynomial time. d) There exists a deterministic Turing machine that can verify their
solutions in polynomial time. Answer: c) There exists a non-deterministic Turing machine
that can verify their solutions in polynomial time.
7. The Chinese Remainder Theorem is used to solve: a) Linear programming problems b)
Quadratic programming problems c) Systems of linear equations d) Systems of
congruences Answer: d) Systems of congruences
8. Which of the following is an example of an NP-complete problem? a) Sorting a list of
numbers b) Finding the shortest path in a graph c) Solving a system of linear equations
d) Traveling Salesperson Problem (TSP) Answer: d) Traveling Salesperson Problem
(TSP)
9. The time complexity of the Euclidean algorithm for finding the GCD of two numbers is: a)
O(n) b) O(log n) c) O(n log n) d) O(n^2) Answer: b) O(log n)
10. The complexity class PSPACE represents the set of decision problems that can be
solved by a: a) Deterministic Turing machine in polynomial space b) Non-deterministic
Turing machine in polynomial space c) Deterministic Turing machine in exponential
space d) Non-deterministic Turing machine in exponential space Answer: a)
Deterministic Turing machine in polynomial space
11. Which of the following is NOT a data structure? a) Array b) Linked List c) Stack d)
Algorithm Answer: d) Algorithm
12. What is the time complexity of inserting an element at the end of an array? a) O(1) b)
O(log n) c) O(n) d) O(n^2) Answer: a) O(1)
13. Which sorting algorithm has the worst-case time complexity of O(n^2)? a) Merge Sort b)
Quick Sort c) Insertion Sort d) Heap Sort Answer: c) Insertion Sort
14. What is the purpose of dynamic programming? a) To solve optimization problems by
breaking them down into overlapping subproblems b) To design efficient algorithms for
sorting and searching c) To analyze the complexity of algorithms d) To implement data
structures like stacks and queues Answer: a) To solve optimization problems by breaking
them down into overlapping subproblems
15. Which data structure follows the Last-In-First-Out (LIFO) principle? a) Queue b) Stack c)
Linked List d) Tree Answer: b) Stack
16. Which of the following is NOT a searching algorithm? a) Binary Search b) Linear Search
c) Depth-First Search d) Bubble Sort Answer: d) Bubble Sort
17. What is the time complexity of a binary search algorithm? a) O(1) b) O(log n) c) O(n) d)
O(n^2) Answer: b) O(log n)
18. Which data structure is used to implement a priority queue? a) Array b) Linked List c)
Stack d) Heap Answer: d) Heap
19. Which algorithm is used to find the shortest path in a weighted graph? a) Breadth-First
Search (BFS) b) Depth-First Search (DFS) c) Dijkstra's Algorithm d) Prim's Algorithm
Answer: c) Dijkstra's Algorithm
20. What is the time complexity of a bubble sort algorithm? a) O(1) b) O(log n) c) O(n) d)
O(n^2) Answer: d) O(n^2)
21. Which of the following is an example of a number-theoretic algorithm? a) QuickSort b)
Dijkstra's algorithm c) Prim's algorithm d) Euclidean algorithm Answer: d) Euclidean
algorithm
22. The time complexity of the Euclidean algorithm for finding the GCD of two numbers is: a)
O(n) b) O(log n) c) O(n log n) d) O(n^2) Answer: b) O(log n)
23. The complexity class P represents the set of decision problems that can be solved by a:
a) Deterministic Turing machine in polynomial time b) Non-deterministic Turing machine
in polynomial time c) Deterministic Turing machine in exponential time d) Non-
deterministic Turing machine in exponential time Answer: a) Deterministic Turing
machine in polynomial time
24. Which of the following is an example of an NP-complete problem? a) Sorting a list of
numbers b) Finding the shortest path in a graph c) Solving a system of linear equations
d) Traveling Salesperson Problem (TSP) Answer: d) Traveling Salesperson Problem
(TSP)
25. The complexity class co-NP represents the set of decision problems for which: a) There
exists a non-deterministic Turing machine that can solve them in polynomial time. b)
There exists a deterministic Turing machine that can solve them in polynomial time. c)
There exists a non-deterministic Turing machine that can verify their solutions in
polynomial time. d) There exists a deterministic Turing machine that can verify their
solutions in polynomial time. Answer: c) There exists a non-deterministic Turing machine
that can verify their solutions in polynomial time.
26. The Chinese Remainder Theorem is used to solve: a) Linear programming problems b)
Quadratic programming problems c) Systems of linear equations d) Systems of
congruences Answer: d) Systems of congruences
27. The time complexity of the Sieve of Eratosthenes algorithm for finding prime numbers up
to a given limit is: a) O(n) b) O(n log n) c) O(n^2) d) O(sqrt(n)) Answer: d) O(sqrt(n))
28. The complexity class PSPACE represents the set of decision problems that can be
solved by a: a) Deterministic Turing machine in polynomial space b) Non-deterministic
Turing machine in polynomial space c) Deterministic Turing machine in exponential
space d) Non-deterministic Turing machine in exponential space Answer: a)
Deterministic Turing machine in polynomial space
29. The Euclidean algorithm is used to find the: a) Greatest Common Divisor (GCD) of two
numbers b) Least Common Multiple (LCM) of two numbers c) Prime factorization of a
number d) Modular inverse of a number Answer: a) Greatest Common Divisor (GCD) of
two numbers
30. The time complexity of the Miller-Rabin primality test algorithm is: a) O(1) b) O(log n) c)
O(n) d) O(k log n) Answer: d) O(k log n)
31. Which of the following algorithms is used to find the greatest common divisor (GCD) of
two numbers? a) QuickSort b) Dijkstra's algorithm c) Euclidean algorithm d) Prim's
algorithm Answer: c) Euclidean algorithm
32. The complexity class P represents the set of decision problems that can be solved by a:
a) Deterministic Turing machine in polynomial time b) Non-deterministic Turing machine
in polynomial time c) Deterministic Turing machine in exponential time d) Non-
deterministic Turing machine in exponential time Answer: a) Deterministic Turing
machine in polynomial time
33. The Chinese Remainder Theorem is used to solve: a) Linear programming problems b)
Quadratic programming problems c) Systems of linear equations d) Systems of
congruences Answer: d) Systems of congruences
34. The time complexity of the Sieve of Eratosthenes algorithm for finding prime numbers up
to a given limit is: a) O(n) b) O(n log n) c) O(n^2) d) O(sqrt(n)) Answer: d) O(sqrt(n))
35. The complexity class co-NP represents the set of decision problems for which: a) There
exists a non-deterministic Turing machine that can solve them in polynomial time. b)
There exists a deterministic Turing machine that can solve them in polynomial time. c)
There exists a non-deterministic Turing machine that can verify their solutions in
polynomial time. d) There exists a deterministic Turing machine that can verify their
solutions in polynomial time. Answer: c) There exists a non-deterministic Turing machine
that can verify their solutions in polynomial time.
36. The Euclidean algorithm is used to find the: a) Greatest Common Divisor (GCD) of two
numbers b) Least Common Multiple (LCM) of two numbers c) Prime factorization of a
number d) Modular inverse of a number Answer: a) Greatest Common Divisor (GCD) of
two numbers
37. The time complexity of the Miller-Rabin primality test algorithm is: a) O(1) b) O(log n) c)
O(n) d) O(k log n) Answer: d) O(k log n)
38. The complexity class PSPACE represents the set of decision problems that can be
solved by a: a) Deterministic Turing machine in polynomial space b) Non-deterministic
Turing machine in polynomial space c) Deterministic Turing machine in exponential
space d) Non-deterministic Turing machine in exponential space Answer: a)
Deterministic Turing machine in polynomial space
39. Which of the following algorithms is used to find the modular inverse of a number? a)
QuickSort b) Dijkstra's algorithm c) Euclidean algorithm d) Extended Euclidean algorithm
Answer: d) Extended Euclidean algorithm
40. The complexity class NP represents the set of decision problems that can be: a) Solved
in polynomial time b) Verified in polynomial time c) Solved in exponential time d) Verified
in exponential time Answer: b) Verified in polynomial time
41. Which of the following algorithms is used to find the greatest common divisor (GCD) of
two numbers? a) QuickSort b) Dijkstra's algorithm c) Euclidean algorithm d) Prim's
algorithm Answer: c) Euclidean algorithm
42. The complexity class P represents the set of decision problems that can be solved by a:
a) Deterministic Turing machine in polynomial time b) Non-deterministic Turing machine
in polynomial time c) Deterministic Turing machine in exponential time d) Non-
deterministic Turing machine in exponential time Answer: a) Deterministic Turing
machine in polynomial time
43. The Chinese Remainder Theorem is used to solve: a) Linear programming problems b)
Quadratic programming problems c) Systems of linear equations d) Systems of
congruences Answer: d) Systems of congruences
44. The time complexity of the Sieve of Eratosthenes algorithm for finding prime numbers up
to a given limit is: a) O(n) b) O(n log n) c) O(n^2) d) O(sqrt(n)) Answer: d) O(sqrt(n))
45. The complexity class co-NP represents the set of decision problems for which: a) There
exists a non-deterministic Turing machine that can solve them in polynomial time. b)
There exists a deterministic Turing machine that can solve them in polynomial time. c)
There exists a non-deterministic Turing machine that can verify their solutions in
polynomial time. d) There exists a deterministic Turing machine that can verify their
solutions in polynomial time. Answer: c) There exists a non-deterministic Turing machine
that can verify their solutions in polynomial time.
46. The Euclidean algorithm is used to find the: a) Greatest Common Divisor (GCD) of two
numbers b) Least Common Multiple (LCM) of two numbers c) Prime factorization of a
number d) Modular inverse of a number Answer: a) Greatest Common Divisor (GCD) of
two numbers
47. The time complexity of the Miller-Rabin primality test algorithm is: a) O(1) b) O(log n) c)
O(n) d) O(k log n) Answer: d) O(k log n)
48. The complexity class PSPACE represents the set of decision problems that can be
solved by a: a) Deterministic Turing machine in polynomial space b) Non-deterministic
Turing machine in polynomial space c) Deterministic Turing machine in exponential
space d) Non-deterministic Turing machine in exponential space Answer: a)
Deterministic Turing machine in polynomial space
49. Which of the following algorithms is used to find the modular inverse of a number? a)
QuickSort b) Dijkstra's algorithm c) Euclidean algorithm d) Extended Euclidean algorithm
Answer: d) Extended Euclidean algorithm
50. The complexity class NP represents the set of decision problems that can be: a) Solved
in polynomial time b) Verified in polynomial time c) Solved in exponential time d) Verified
in exponential time Answer: b) Verified in polynomial time
Modular Arithmetic in Number Theory:
51. What is the result of 7 modulo 3? a) 0 b) 1 c) 2 d) 3 Answer: c) 2
52. Which of the following is equivalent to 5 modulo 7? a) 2 b) 3 c) 5 d) 7 Answer: c) 5
53. What is the multiplicative inverse of 9 modulo 11? a) 1 b) 2 c) 9 d) 10 Answer: d) 10
54. Which of the following is true for any positive integers a, b, and n? a) (a + b) mod n = (a
mod n) + (b mod n) b) (a * b) mod n = (a mod n) * (b mod n) c) (a - b) mod n = (a mod n) -
(b mod n) d) All of the above Answer: d) All of the above
55. What is the result of 2^5 modulo 7? a) 1 b) 2 c) 3 d) 4 Answer: c) 3
56. Which of the following is true for any positive integers a and n? a) a^0 mod n = 1 b) a^1
mod n = a mod n c) a^2 mod n = (a mod n)^2 d) All of the above Answer: d) All of the
above
57. What is the result of 3^(-1) modulo 5? a) 0 b) 1 c) 2 d) 3 Answer: c) 2
58. Which of the following is true for any positive integers a, b, and n? a) If a ≡ b (mod n),
then a^2 ≡ b^2 (mod n) b) If a ≡ b (mod n), then a^3 ≡ b^3 (mod n) c) If a ≡ b (mod n),
then a^k ≡ b^k (mod n) for any positive integer k d) All of the above Answer: d) All of the
above
59. What is the result of 4^(-1) modulo 9? a) 0 b) 1 c) 2 d) 4 Answer: c) 2
60. Which of the following is true for any positive integers a, b, and n? a) If a ≡ b (mod n),
then a + n ≡ b (mod n) b) If a ≡ b (mod n), then a - n ≡ b (mod n) c) If a ≡ b (mod n), then
a + kn ≡ b (mod n) for any integer k d) All of the above Answer: d) All of the above
61. What is the result of 12 modulo 5? a) 0 b) 1 c) 2 d) 3 Answer: c) 2
62. Which of the following is equivalent to 8 modulo 4? a) 0 b) 1 c) 2 d) 4 Answer: a) 0
63. What is the multiplicative inverse of 5 modulo 9? a) 1 b) 2 c) 5 d) 9 Answer: b) 2
64. Which of the following is true for any positive integers a, b, and n? a) (a + b) mod n = (a
mod n) + (b mod n) b) (a * b) mod n = (a mod n) * (b mod n) c) (a - b) mod n = (a mod n) -
(b mod n) d) All of the above Answer: d) All of the above
65. What is the result of 3^4 modulo 7? a) 1 b) 2 c) 3 d) 4 Answer: b) 2
66. Which of the following is true for any positive integers a and n? a) a^0 mod n = 1 b) a^1
mod n = a mod n c) a^2 mod n = (a mod n)^2 d) All of the above Answer: d) All of the
above
67. What is the result of 6^(-1) modulo 11? a) 0 b) 1 c) 6 d) 11 Answer: c) 6
68. Which of the following is true for any positive integers a, b, and n? a) If a ≡ b (mod n),
then a^2 ≡ b^2 (mod n) b) If a ≡ b (mod n), then a^3 ≡ b^3 (mod n) c) If a ≡ b (mod n),
then a^k ≡ b^k (mod n) for any positive integer k d) All of the above Answer: d) All of the
above
69. What is the result of 7^(-1) modulo 10? a) 0 b) 1 c) 3 d) 7 Answer: c) 3
70. Which of the following is true for any positive integers a, b, and n? a) If a ≡ b (mod n),
then a + n ≡ b (mod n) b) If a ≡ b (mod n), then a - n ≡ b (mod n) c) If a ≡ b (mod n), then
a + kn ≡ b (mod n) for any integer k d) All of the above Answer: d) All of the above