Algorithm Analysis questions

Q29

GATE CS 2023 CSAlgorithm AnalysisMSQ1 mark
Let ff and gg be functions of natural numbers given by f(n)=nf(n) = n and g(n)=n2g(n) = n^2.
Which of the following statements is/are TRUE?
More than one option can be correct.
Show answer without attempting

Answer: A, C

Q54

GATE CS 2023 CSAlgorithm AnalysisMSQ2 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 f1(n)f_1(n) and f2(n)f_2(n) denote the number of times the statement "x=x+1x = x + 1" is executed in Function_1 and Function_2, respectively.

Which of the following statements is/are TRUE?
More than one option can be correct.
Show answer without attempting

Answer: A, D

0/20 correct0 marks

Related topics in Algorithms