- Below is the detaled explanation of the above mentioned
problem.
- So a software developer wants to store a list of supermarket
products which are made up of code in binary(i.e, string of 0's and
1's) and a availability(which is a boolean value), but if the
developer decides to store the list in base-10 that can be very
inefficient.
- As the binary strings can be very large it is very difficult to
store those values in base-10 as in most of the languages we do not
have a datatype that can support integers having more than 64
bits.
- As these days every computer supports 64 bit architecture so it
is the max limit to store integers in most of the languages.
- In some languages like python higher bits integers can also be
stored but it is a time consuming process to store very large
integers and peforming some calculations on them.
- Consider an example , let the code of a product be a string of
length 10^5 (consisting of 0's and 1's) and we now convert this to
base-10 , now it is impossible to store these in basic
datatypes(int, long long) in most of the languages like C, C++,
java as they do not have that much limit but yes we can store them
using python but performing calculations on a string of length 10^5
is very very faster than on a base-10 converted integer.
- In C/C++, 10^8 operations are performed in 1sec(2
in java and 5
in python) so it is very faster then converting it in base-10 and
then dealing with it.
So there is both storage issue and time complexity also
increases , so it is a bad idea to convert binary string to base-10
for long string.
So if you still have any doubt regarding this solution please
feel free to ask it in the comment section below and if it is
helpful then please upvote this solution, THANK
YOU.