Aspire Faculty ID #18919 · Topic: UGC NET Computer Science Nov 2020 (Paper II) · Just now
UGC NET Computer Science Nov 2020 (Paper II)

Consider the following pseudo-code fragment, where $a$ and $b$ are integer variables that have been initialized:

Pre-conditions: $(a>1\land a<b)$

Assume that overflow never occurs.

int $x=0$; int $p=1$;

while $(p<b)$ {
$p=p*a$;
$x=x+1$;
}

When the while loop terminates, what will be the value of $x$ in terms of $a$ and $b$?

Solution

Initially,

$p=1=a^0$

After $1$ iteration:

$p=a^1$

After $2$ iterations:

$p=a^2$

After $x$ iterations:

$p=a^x$

Loop stops when:

$p\ge b$

So,

$a^x\ge b$

Minimum such value of $x$ is:

$x=\lceil \log_a b\rceil$

Previous 10 Questions — UGC NET Computer Science Nov 2020 (Paper II)

Nearest first

Next 10 Questions — UGC NET Computer Science Nov 2020 (Paper II)

Ascending by ID
1
In HTML, $&lt;map&gt;$ tag is used for
Topic: UGC NET Computer Science Nov 2020 (Paper II)
2
Suppose you are compiling on a machine with $1$-byte chars, $2$-byte shorts, $4$-byte ints, and $8$-byte doubles, and w…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
3
Consider the following recursive Java function $f$ that takes two long arguments and returns a float value:public stati…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
4
The data node and name node in HADOOP are
Topic: UGC NET Computer Science Nov 2020 (Paper II)
5
Consider a relational schema$S=(U,V,W,X,Y,Z)$on which the following functional dependencies hold:$\{U\to V,\ VW\to X,\ …
Topic: UGC NET Computer Science Nov 2020 (Paper II)
6
&nbsp;Consider a hypothetical machine with $3$ pages of physical memory, $5$ pages of virtual memory, and$\langle A,B,C…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
7
Consider a disk system having $60$ cylinders. Disk requests are received for cylinders $10,22,20,2,40,6,38$ in that ord…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
8
Suppose you have a Linux file system where the block size is $2K$ bytes, a disk address is $32$ bits, and an i-node con…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
9
Consider a single-level page table system, with the page table stored in the memory. If the hit rate to TLB is $80\%$, …
Topic: UGC NET Computer Science Nov 2020 (Paper II)
10
Which of the following UML diagrams has a static view?
Topic: UGC NET Computer Science Nov 2020 (Paper II)
Ask Your Question or Put Your Review.

loading...