edited by
6,740 views
31 votes
31 votes

Suppose the domain set of an attribute consists of signed four digit numbers. What is the percentage of reduction in storage space of this attribute if it is stored as an integer rather than in character form?

  1. $\text{80%}$
  2. $\text{20%}$
  3. $\text{60%}$
  4. $\text{40%}$
edited by

3 Answers

Best answer
58 votes
58 votes
I assume byte addressable memory- nothing smaller than a byte can be used.

We have four digits. So, to represent signed 4 digit numbers we need 5 bytes- 4 for four digits and 1 for the sign (like -7354). So, required memory = 5 bytes

Now, if we use integer, the largest number needed to represent is 9999 and this requires 2 bytes of memory for signed representation (one byte can represent only 256 unique integers).

So, memory savings while using integer is $\frac{(5 - 2)}{5} = \frac{3}{5} = 60\%$

Correct Answer: $C$
edited by
17 votes
17 votes

signed four digit numbers

First position for the sign, the subsequent four positions for the digits.

__ __ __ __ __

It is common knowledge that 1 char takes 1 Byte. So, this will take 5 Bytes.

 

The size of int back in the day was 2 Bytes. Now it can take 4 Bytes with modern compilers. Since this is a 1998 question, let's assume the size of int is 2 Bytes :P So, this whole integer takes 2 Bytes.

 

Now the easiest part:

$\frac{5-2}{5}*100\%$

=> $60 \%$

Option C


Dennis Ritchie, Page number 36:

char [...] a single byte

and [the size of an] int [is] either 16 or 32 bits

5 votes
5 votes
answer - C

numbers stored as characters

total numbers to be represented 20K

each number represented using 5B

total space required 100KB

numbers stored as integers

every number can be represented using 2B

total space required 40KB

saving 60KB
Answer:

Related questions

31 votes
31 votes
2 answers
1
Kathleen asked Sep 25, 2014
8,100 views
The octal representation of an integer is $(342)_8$. If this were to be treated as an eight-bit integer in an $8085$ based computer, its decimal equivalent is$226$$-98$$7...
24 votes
24 votes
1 answer
2
Kathleen asked Sep 25, 2014
8,167 views
The function represented by the Karnaugh map given below is$A.B$$AB+BC+CA$$\overline{B \oplus C}$$A.BC$
23 votes
23 votes
3 answers
3
Kathleen asked Sep 26, 2014
4,968 views
Design a synchronous counter to go through the following states:$$1, 4, 2, 3, 1, 4, 2, 3, 1, 4 \dots $$
42 votes
42 votes
4 answers
4
Kathleen asked Sep 25, 2014
9,977 views
What happens when a bit-string is XORed with itself $n$-times as shown:$\left[B \oplus (B \oplus ( B \oplus (B \dots n \text{ times}\right]$complements when $n$ is evenco...