GATE | GATE-CS-2006 | Question 55
Consider these two functions and two statements S1 and S2 about them
S1: The transformation form work1 to work2 is valid, i.e., for any program state and input arguments, work2 will compute the same output and have the same effect on program state as work1
S2: All the transformations applied to work1 to get work2 will always improve the performance (i.e reduce CPU time) of work2 compared to work1
(A) S1 is false and S2 is false
(B) S1 is false and S2 is true
(C) S1 is true and S2 is false
(D) S1 is true and S2 is true
Explanation: (S1): Take an counter example, Array = [1, 2, 3, 4, 5] and i = 0. Let j = (i+2), so j = (0+2) = 2.
For this example work1 and work2 will return 1 and 0 respectively. So, statement is false.
(S2): We can not compare given program on basis of runtime. We can not say the performance of work2 will always be better than work1 for any inputs. So, statement is false.
Option (A) is correct.
Quiz of this Question
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.