The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+15 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?

- $\text{80%}$
- $\text{20%}$
- $\text{60%}$
- $\text{40%}$

+29 votes

Best answer

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$

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$

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

+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

@meghna please help me with this line

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.

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.

- All categories
- General Aptitude 1.8k
- Engineering Mathematics 7.3k
- Digital Logic 2.9k
- Programming & DS 4.9k
- Algorithms 4.3k
- Theory of Computation 6k
- Compiler Design 2.1k
- Databases 4.1k
- CO & Architecture 3.4k
- Computer Networks 4.1k
- Non GATE 1.4k
- Others 1.4k
- Admissions 596
- Exam Queries 577
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

49,541 questions

54,071 answers

187,187 comments

70,978 users