GATE CS 2023 · Question 54 · Algorithms · Multiple select (MSQ) · 2 marks · no negative marks
Consider functions Function_1 and Function_2 expressed in pseudocode as follows:
Function_1 while n > 1 do for i = 1 to n do x = x + 1; end for n = ⌊n/2⌋; end while Function_2 for i = 1 to 100 * n do x = x + 1; end for
Let f₁(n) and f₂(n) denote the number of times the statement "x = x + 1" is executed in Function_1 and Function_2, respectively.
Which of the following statements is/are TRUE?
- (A) f₁(n) ∈ Θ(f₂(n))
- (B) f₁(n) ∈ o(f₂(n))
- (C) f₁(n) ∈ ω(f₂(n))
- (D) f₁(n) ∈ O(n)
Answer
Answer (A), (D)
Answer from the official GATE CS 2023 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes