Aspire Faculty ID #19239 · Topic: UGC NET Computer Science June 2019 (Paper II) · Just now
UGC NET Computer Science June 2019 (Paper II)

Consider the following pseudo-code fragment in which an invariant for the loop is $m \times x^k=p^n$ and $k\ge 0$.

Pre-conditions: $p\ge 1$ and $n\ge 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 = floor(k / 2);
}

Which of the following must be true at the end of the while loop?

Solution

Given loop invariant is

$m \times x^k=p^n$

At the end of the while loop, condition becomes false.

So,

$k=0$

Putting $k=0$ in invariant,

$m \times x^0=p^n$

Since,

$x^0=1$

Therefore,

$m=p^n$

Previous 10 Questions — UGC NET Computer Science June 2019 (Paper II)

Nearest first
1
Suppose that a computer program takes $100$ seconds of execution time on a computer with multiplication operation respo…
Topic: UGC NET Computer Science June 2019 (Paper II)
2
How many address lines and data lines are required to provide a memory capacity of $16K \times 16$?
Topic: UGC NET Computer Science June 2019 (Paper II)
3
Consider the equation $(146)b+(313){b-2}=(246)_8$ Which of the following is the value of $b$?
Topic: UGC NET Computer Science June 2019 (Paper II)
4
The parallel bus arbitration technique uses an external priority encoder and a decoder. Suppose, a parallel arbiter has…
Topic: UGC NET Computer Science June 2019 (Paper II)
5
For a magnetic disk with concentric circular tracks, the seek latency is not linearly proportional to the seek distance…
Topic: UGC NET Computer Science June 2019 (Paper II)
6
What will be the number of states when a $MOD-2$ counter is followed by a $MOD-5$ counter?
Topic: UGC NET Computer Science June 2019 (Paper II)
7
The fault can be easily diagnosed in the micro-program control unit using diagnostic tools by maintaining the contents …
Topic: UGC NET Computer Science June 2019 (Paper II)
8
How many different Boolean functions of degree $n$ are there?
Topic: UGC NET Computer Science June 2019 (Paper II)
9
Suppose that the register $A$ and the register $K$ have the bit configuration. Only the three leftmost bits of $A$ are …
Topic: UGC NET Computer Science June 2019 (Paper II)
10
Which type of addressing mode requires the least number of memory references?
Topic: UGC NET Computer Science June 2019 (Paper II)

Next 10 Questions — UGC NET Computer Science June 2019 (Paper II)

Ascending by ID
1
Consider the following C-code fragment running on a $32$-bit x86 machine:typedef struct { union { unsigned char a; unsi…
Topic: UGC NET Computer Science June 2019 (Paper II)
2
What is the output of the following JAVA program? public class Good { private int m; public Good(int m) { this.m = m; }…
Topic: UGC NET Computer Science June 2019 (Paper II)
3
Consider the following C++ function $f()$: unsigned int f(unsigned int n) { unsigned int b = 0; while (n) { b = b + (n …
Topic: UGC NET Computer Science June 2019 (Paper II)
4
Which of the following statements is/are true?$P$: In a scripting language like JavaScript, types are typically associa…
Topic: UGC NET Computer Science June 2019 (Paper II)
5
Which of the following statements is/are true?$P$: An XML document with correct syntax as specified by W3C is called "W…
Topic: UGC NET Computer Science June 2019 (Paper II)
6
Consider a raster system with resolution $640$ by $480$. What size is frame buffer in bytes for this system to store $1…
Topic: UGC NET Computer Science June 2019 (Paper II)
7
Consider the following statements regarding $2D$ transforms in computer graphics: $S1$: [ 1 0 …
Topic: UGC NET Computer Science June 2019 (Paper II)
8
In the context of $3D$ computer graphics, which of the following statements is/are true? $P$: Orthographic transformati…
Topic: UGC NET Computer Science June 2019 (Paper II)
9
Using the Phong reflectance model, the strength of the specular highlight is determined by the angle between:
Topic: UGC NET Computer Science June 2019 (Paper II)
10
Which of the following has same expressive power with regard to relational query language? $(a)$ Relational algebra and…
Topic: UGC NET Computer Science June 2019 (Paper II)
Ask Your Question or Put Your Review.

loading...