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

Consider the following C++ function $f()$:

unsigned int f(unsigned int n) {
unsigned int b = 0;
while (n) {
b = b + (n bitwise AND 1);
n = n shifted right by 1;
}
return b;
}

The function $f()$ returns the integer that represents the $P$ in the binary representation of positive integer $n$, where $P$ is:

Solution

The expression $n$ bitwise AND $1$ checks the last bit of $n$.

If the last bit is $1$, then $b$ increases by $1$.

After that, $n$ is shifted right by one bit.

So, the loop checks each bit of $n$ one by one.

Therefore, $b$ counts the total number of $1$'s in the binary representation of $n$.

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

Nearest first
1
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)
2
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)
3
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-…
Topic: UGC NET Computer Science June 2019 (Paper II)
4
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)
5
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)
6
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)
7
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)
8
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)
9
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)
10
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)

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

Ascending by ID
1
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)
2
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)
3
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)
4
Consider the following statements regarding $2D$ transforms in computer graphics: $S1$: [ 1 0 …
Topic: UGC NET Computer Science June 2019 (Paper II)
5
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)
6
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)
7
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)
8
With respect to relational algebra, which of the following operations are included for mathematical set theory? $(a)$ J…
Topic: UGC NET Computer Science June 2019 (Paper II)
9
In relational databases, if relation $R$ is in $BCNF$, then which of the following is true about relation $R$?
Topic: UGC NET Computer Science June 2019 (Paper II)
10
Which of the following key constraints is required for functioning of foreign key in the context of relational database…
Topic: UGC NET Computer Science June 2019 (Paper II)
Ask Your Question or Put Your Review.

loading...