Friday, 22 November 2019

UGC NET PAPER 2 June 2019 Question 21 (Shift-I)

21. Consider the following pseudo-code fragment in which an invariant for the loop is " m * xk = p nand k ≥ 0 " (Here, p and n are integer variables that have been initialized):
/* Pre-conditions:p ≥ 1 ∧ n ≥ 0 */
/* Assume that overflow never occurs */
int x=p; int k=n; int m=1;
while(k< >0)
{
if(k is odd) then m=m*x;
x=x*x;
k=⌊(k/2)⌋; /* floor(k/2) */
}
Which of the following must be true at the end of the while loop?
A x=pn
B m=pn
C p=xn
D p=mn
ANS. B

PreviousNext
UGC NET CS 2018 July - II Question 20UGC NET CS 2018 July - II Question 22

No comments:

Post a Comment

UGC NET Computer Science December 2019 | Question 16

Question 16 In a certain coding language. 'AEIOU' is written as 'TNHDZ'. Using the same coding language. 'BFJPV' wil...

Popular Posts