Bitmap explanation and its application

Baidu Encyclopedia:

       From "Programming Pearl". The so-called Bit-map is to use a bit to mark the Value corresponding to an element, and the Key is the element. Since the data is stored in the unit of Bit, the storage space can be greatly saved.

        A byte occupies 8 bits. If the value of each bit is yes or no, that is, binary 0 or 1, if the position of the bit is used to represent the presence or absence of the array value, then 0 means that the value has not appeared, and 1 means The array value has appeared.

 Advantages: 1. High operational efficiency, no comparison and shift are allowed;

            2. Occupy less memory, such as N=10000000; only need to occupy memory as N/8=1250000Byte=1.25M. 

 Disadvantage: All data cannot be repeated. That is, it is not possible to sort and find duplicate data. 

for example:

An array arr{2,5,4,3}, using the bitmap algorithm:

byte[0]

 We traverse the byte array and output it in order from small to large;

        The bitmap algorithm is suitable for processing a large number of continuous data problems, which can greatly save space;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326490212&siteId=291194637