1.5k 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.5k 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
+5
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.
+1

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!
0

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)

I AM NOT GETTING IT

0
@deepanshu 9999 can be represented with 14-bit(as 2^13=8192<9999 so 2^14=16384>9999) now 2-bit will be remaining so 1-bit will use for sign bit as MSB ,so approximately 15-bit (2 Byte) will require .

one Byte have 8-bit so 2^8=256 unique integers will be there and 2-byte have 16-bit so 2^16= 65536 unique address will be there.

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

1
2