edited by
6,264 views
6 votes
6 votes

If a variable can take only integral values from $0$ to $n$, where $n$ is an integer, then the variable can be represented as a bit-field whose width is $($the log in the answer are to the base $2$, and $\left \lceil \log_{}{n} \right \rceil$ means the floor of $\log_{}{n}\ )$

  1. $\left \lceil \log (n) \right \rceil + 1 \text{ bits}$
  2. $\left \lceil \log (n-1) \right \rceil  + 1 \text{ bits}$
  3. $\left \lceil \log (n+1) \right \rceil + 1\text{ bits}$
  4.  None of the above
edited by

4 Answers

9 votes
9 votes
Option D is correct.

log 0 is $-\infty$ but a variable having value 0 requires 1 bit to store.

This eliminates option A and B.

For option C take n=3, it will give 3 bits to store value 3. This is false, 3 requires 2 bits only(11 in binary).

Thus, option C is also incorrect.
3 votes
3 votes
Here we have to choose a variable from the interval (0,n]

Note that a number of the form 2^m has m+1 bits.

If 2^m<=n<=2^(m+1)

then n should also have m+1 bits.

Thus any number chosen in between (0,n] should have [log (n)]+1 bits.

So,option A is correct.
2 votes
2 votes
Let n=8,  (i.e variable take value from 0 to 8) (take worst case)

in binary:  x = log8(base to 2)  = 3

But for representing the 8, we need at least  (x+1) bit,

similarly for n bit, [log n(base to 2) + 1] bit required.
1 votes
1 votes
its given from 0 to n , which means n should be greater than 0 . one cant say from 0 to 0 . and 0 and n both are included ,if its saying from 0 to n . Just you cant take log 0 ,because minimum it will be from 0 to 1 . so option A is only satisfied
Answer:

Related questions

4 votes
4 votes
3 answers
1
Arjun asked Apr 22, 2018
3,779 views
Given $\sqrt{224_{r}}$= $13$$_{r}$ the value of radix $r$ is$10$$8$$6$$5$
4 votes
4 votes
3 answers
2
Arjun asked Apr 22, 2018
4,182 views
A computer uses ternary system instead of the traditional systen, An $n$ bit string in the binary system will occupy$3+n$ ternary digits$2n/3$ ternary digits$n$$\log_{2}3...
4 votes
4 votes
2 answers
4
Arjun asked Apr 22, 2018
1,830 views
Any set of Boolean operation that is sufficient to represent all Boolean expression is said to be complete. Which of the following is not complete ?$\text{{AND, OR}}$$\te...