1.2k views

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 | 1.2k views

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\%$
selected by
+2
9999 in binary requires 14 bits. so, 2 bits are remaining and 1 we can use for sign.
0

I didn't get this please somebody explain.

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

0
Why are we not using BCD instead of binary?
0

Arjun sir, here integer size as 2B is an assumption???

0
Not an assumption - taking the minimum possible size required for an integer for the given problem.
0

but @ Arjun Sir nowhere maximum reduction is mentioned, so how can we assume only 2B??

If I take 4B, then (5-4)/5 gives 20% savings. How to avoid such dilemma?

0
And 20 or 60 is maximum? :)
0
alright sir, thanks!

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
0
You assumed 20K entries to be stored rt?
0
yes