1. What does the term "polynomial time" refer to in algorithm
complexity?
A. An algorithm with complexity of O(n^k) for some constant k
B. An algorithm that requires logarithmic steps
C. An algorithm that runs in constant time
D. An algorithm with complexity of O(log n)
Answer: a) An algorithm with complexity of O(n^k) for some constant
k
Rationale: Polynomial time refers to an algorithm whose time
complexity is a polynomial function of the input size, such as O(n^2),
O(n^3), etc.
2. Which of the following is a characteristic of an NP-hard problem?
A. It can be solved in polynomial time
B. It can be solved in exponential time
C. It has no known solution algorithm
D. It can be solved by a greedy approach
Answer: b) It can be solved in exponential time
Rationale: NP-hard problems are known for their difficulty, and solving
them often requires exponential time.
3. Which of the following operations is performed by a Binary Search
Tree (BST)?
,A. Insertions in O(n)
B. Deletions in O(log n)
C. Search in O(n)
D. All of the above
Answer: b) Deletions in O(log n)
Rationale: In a balanced Binary Search Tree (BST), both insertion and
search operations take O(log n), and deletion also happens in O(log n)
in a balanced tree.
4. Which of the following is not an advantage of dynamic
programming?
A. It solves problems with overlapping subproblems
B. It avoids recalculating solutions to subproblems
C. It guarantees an optimal solution
D. It reduces the time complexity to linear time
Answer: d) It reduces the time complexity to linear time
Rationale: Dynamic programming may not always reduce time
complexity to linear time; it is typically used for problems with
overlapping subproblems and optimal substructure but may not always
give linear time solutions.
5. What is the purpose of a "priority queue"?
A. To store elements in a specific order based on priority
B. To organize data in ascending order
C. To efficiently find the smallest element
, D. To store unordered elements
Answer: a) To store elements in a specific order based on priority
Rationale: A priority queue stores elements based on their priority,
with the highest (or lowest) priority element being dequeued first.
6. Which type of graph is used in representing state transitions in finite
state machines?
A. Directed Graph
B. Undirected Graph
C. Tree
D. Bipartite Graph
Answer: a) Directed Graph
Rationale: A Directed Graph is used to represent state transitions in
finite state machines because the edges indicate transitions from one
state to another.
7. In which data structure is the Depth First Search (DFS) algorithm
most commonly used?
A. Queue
B. Stack
C. Array
D. Hash Map
Answer: b) Stack
Rationale: DFS is typically implemented using a stack (either explicitly
or via recursion).
complexity?
A. An algorithm with complexity of O(n^k) for some constant k
B. An algorithm that requires logarithmic steps
C. An algorithm that runs in constant time
D. An algorithm with complexity of O(log n)
Answer: a) An algorithm with complexity of O(n^k) for some constant
k
Rationale: Polynomial time refers to an algorithm whose time
complexity is a polynomial function of the input size, such as O(n^2),
O(n^3), etc.
2. Which of the following is a characteristic of an NP-hard problem?
A. It can be solved in polynomial time
B. It can be solved in exponential time
C. It has no known solution algorithm
D. It can be solved by a greedy approach
Answer: b) It can be solved in exponential time
Rationale: NP-hard problems are known for their difficulty, and solving
them often requires exponential time.
3. Which of the following operations is performed by a Binary Search
Tree (BST)?
,A. Insertions in O(n)
B. Deletions in O(log n)
C. Search in O(n)
D. All of the above
Answer: b) Deletions in O(log n)
Rationale: In a balanced Binary Search Tree (BST), both insertion and
search operations take O(log n), and deletion also happens in O(log n)
in a balanced tree.
4. Which of the following is not an advantage of dynamic
programming?
A. It solves problems with overlapping subproblems
B. It avoids recalculating solutions to subproblems
C. It guarantees an optimal solution
D. It reduces the time complexity to linear time
Answer: d) It reduces the time complexity to linear time
Rationale: Dynamic programming may not always reduce time
complexity to linear time; it is typically used for problems with
overlapping subproblems and optimal substructure but may not always
give linear time solutions.
5. What is the purpose of a "priority queue"?
A. To store elements in a specific order based on priority
B. To organize data in ascending order
C. To efficiently find the smallest element
, D. To store unordered elements
Answer: a) To store elements in a specific order based on priority
Rationale: A priority queue stores elements based on their priority,
with the highest (or lowest) priority element being dequeued first.
6. Which type of graph is used in representing state transitions in finite
state machines?
A. Directed Graph
B. Undirected Graph
C. Tree
D. Bipartite Graph
Answer: a) Directed Graph
Rationale: A Directed Graph is used to represent state transitions in
finite state machines because the edges indicate transitions from one
state to another.
7. In which data structure is the Depth First Search (DFS) algorithm
most commonly used?
A. Queue
B. Stack
C. Array
D. Hash Map
Answer: b) Stack
Rationale: DFS is typically implemented using a stack (either explicitly
or via recursion).