Aspirant Academy

MCQ

Paper - II (vii) — Algorithms MCQ - Practice Questions with Answers

Solve 44 Paper - II (vii) — Algorithms questions for RAS/RPSC preparation.

Practice questions

Q1For sufficiently large n, which time complexity grows faster: O(n log n) or O(n^2)?

A Growth depends only on the compiler used
B Both grow at exactly the same rate
C O(n^2) grows faster
D O(n log n) grows faster
Explanation

As n becomes large, n squared grows faster than n log n because n/log n tends to increase without bound. This is why an O(n log n) sorting algorithm is usually preferred over an O(n^2) one for large inputs.

Q2For a binary tree, which traversal visits the left subtree first, then the root node, and then the right subtree?

A Level-order traversal
B Postorder traversal
C Preorder traversal
D Inorder traversal
Explanation

Inorder traversal of a binary tree is defined by the sequence left subtree, root, and right subtree. This makes it especially important for binary search trees, where it lists keys in sorted order.

Q3What does Big-O notation primarily express in algorithm analysis?

A An asymptotic upper bound on growth with input size
B The programming language used to implement the algorithm
C The exact running time in seconds on a particular computer
D The number of syntax errors in a program
Explanation

Big-O notation is used to describe an upper bound on the growth of an algorithm resource such as time or memory as input size increases. It suppresses constant factors and lower-order terms for large-input comparison.

Q4Which problem is a standard example where a greedy strategy gives an optimal solution when edges are chosen by increasing weight with cycle checks?

A Matrix multiplication by multiplying matrices strictly left to right
B 0/1 knapsack with arbitrary weights and values
C Minimum spanning tree using Kruskal's algorithm
D Travelling salesman problem by always taking the nearest city
Explanation

Kruskal's algorithm is a classic greedy algorithm for the minimum spanning tree problem. It repeatedly selects the smallest edge that does not create a cycle, and this safe-choice rule leads to an optimal spanning tree.

Q5If an algorithm has running time O(n), what does this notation primarily express?

A An asymptotic upper bound on the growth of running time
B The exact number of machine instructions executed for every input
C A guarantee that the algorithm is faster than every O(n log n) algorithm on small inputs
D A lower bound showing that the running time must be at least linear
Explanation

O(n) states that beyond some input size, the running time is bounded above by a constant multiple of n. It is about growth rate, not an exact step count.

You've seen 5 of 44 sample questions

Unlimited practice on Paper - II (vii) — Algorithms comes with the RAS Test Series + Practice pack or Gate Pass.

More questions

6In a binary tree, which visiting order is used by preorder traversal?

ALeft subtree, root, right subtree
BRoot, left subtree, right subtree
CNodes level by level from top to bottom
DLeft subtree, right subtree, root

7Which pair correctly matches the asymptotic notation with its usual meaning?

AO: upper bound, Ω: lower bound
BO: memory only, Ω: time only
CO: lower bound, Ω: upper bound
DO: exact bound, Ω: average case only

8Which pair correctly matches the algorithmic strategy with a typical feature?

ABranch and bound - searches partial solutions and prunes those that cannot beat the current best
BGreedy method - uses an incumbent bound to prune impossible branches
CInorder traversal - visits root first and then both subtrees
DLevel-order traversal - recursively prints left subtree, root, and right subtree

9Which statement best describes the role of a bound in a branch and bound method for an optimization problem?

AIt converts every optimization problem into a sorting problem
BIt guarantees that no memory is needed for live nodes
CIt stores the final answer before the search begins
DIt estimates the best possible value reachable from a partial solution

10If a traversal visits every node of a binary tree exactly once and does constant work per node, what is its time complexity for n nodes?

AO(n)
BO(1)
CO(n log n)
DO(log n)

11If an algorithm has time complexity O(n), how does its running time grow when the input size n is doubled, ignoring constants and lower-order terms?

AIt becomes roughly twice as large
BIt becomes roughly four times as large
CIt stays exactly unchanged
DIt becomes roughly the logarithm of the old running time

12Which statement best describes a greedy algorithm?

AIt enumerates all possible solutions before choosing an answer
BIt delays every decision until the complete input has been sorted
CIt repeatedly makes the best immediate choice according to a local criterion
DIt always gives an optimal answer for every optimization problem

13For a binary tree, which traversal visits the left subtree first, then the root, and then the right subtree?

ALevel-order traversal
BPreorder traversal
CInorder traversal
DPostorder traversal

14A recursive traversal visits every node of a binary tree exactly once. If the tree has n nodes, what is its time complexity?

AO(n)
BO(n^2)
CO(log n)
DO(n log n)

15In a binary tree traversal, which order is followed by preorder traversal?

AVisit the left subtree, then the root, then the right subtree
BVisit the root, then the left subtree, then the right subtree
CVisit all nodes level by level from top to bottom
DVisit the left subtree, then the right subtree, then the root

More topics in Programming & Data Structures (Senior CI)

Explore other subjects