Question 6665 – UGC NET CS 2017 Jan- paper-3
November 25, 2023DSSSB PGT 2021
November 25, 2023Question 13217 – Algorithms
Two algorithms A and B take n2 days and 2n seconds respectively to solve a problem on an instance of size n. What is the size of the smallest instance for which algorithm A outperforms B in the given choices?
Correct Answer: C
Question 532 Explanation:
A = n2 days = n2 × 24 × 60 × 60 sec
B = 2n sec
The question is asking for what minimum value of n, A will take less time than B.
Let’s take option wise
A) n=10,
A = 102 × 24 × 60 × 60 = 2400 × 3600 sec
B = 210 = 1024 sec
Wrong.
B) n=20
A = 202 × 24 × 60 × 60 = 34560000
B = 220 = 1048576
Wrong.
C) n=30,
A = 302 × 24 × 3600 = 77760000
B = 230 = 1073741824
Yes, for n=30, A outperforms B.
B = 2n sec
The question is asking for what minimum value of n, A will take less time than B.
Let’s take option wise
A) n=10,
A = 102 × 24 × 60 × 60 = 2400 × 3600 sec
B = 210 = 1024 sec
Wrong.
B) n=20
A = 202 × 24 × 60 × 60 = 34560000
B = 220 = 1048576
Wrong.
C) n=30,
A = 302 × 24 × 3600 = 77760000
B = 230 = 1073741824
Yes, for n=30, A outperforms B.
10
20
30
40
Subscribe
Login
0 Comments