Bitmap sort

xiaoxiao2021-03-05  28

1. The understanding of the bitmap We all understand the mode in which the mediate map is stored in a graphic format, in fact, in a small square of the pixel, a single vertical and horizontal accumulation. Every small square represents a color, of course if it is black and white The two-color diagram is more simple, only one bit bit can be said. This is similar to our data in the computer, and the memory module is also like a one-sized BIT bit cross. Because of this inspiration, we found that a Bit race is like a column, the order is quite rigorous, and if our data can pass through a conversion method (logically), it corresponds to the Bit bit one by one. Then we output it in the order of Bit bits is not sorted data collection? 2. The concept of index passes the above description, we can easily think of the same thing - index. Index is undoubtedly important for our database. So now there are now a large number of single-table queries that have completely dominates it. Its and bitmaps are similarity: If we regard each line of data as a unit of data, then the index can be seen as the data The conversion mode is mapped to a storage space. If the order of the data and the index is consistent, the order of the order is obtained when we accesses the storage space, of course, in many cases, indexes It is part of the data, but there is a function index in Oracle, it fully expresses this transformation method and mapping. 3. A clever method of sorting is natural and sorting, because it is the most Essential ordered carrier. One problem is as follows: All 7-digit digital phone numbers in a city require us to output in order: Analyze: The problem of problem - is the condition of the problem - 7 digits, simple See the environment of 0000000 to 9999999 - a city's phone number, quantity, very likely close to 10 million, any time and space cost of any sorting method is very large. Lenovo: seize the meaning of the problem, phone number in this A realistic meaning on the problem is that the phone number is a seat on the entire phone number collection. It is more featured that the telephone number itself reflects such a bit information. If we set up 10 million BIT bits, each one indicates that Whether the phone number is present (setting 1 is existent, 0- does not exist), the bit number is the phone number itself, then we traverse all the bit, the number of phone numbers are output, isn't it the number of phone numbers? Ingenious: Because we use the significance of the data itself! Description process: 1. Initialize the entire BIT bit group to 0 (000000000000 ... 00000000) 2. Read all numbers, on the BIT corresponding to the number Set 1 3. Cycle: for (int i = 0; i <10000000; i) {// i is the phone number IF (bit [i] == 1) {Print i;}} 4. Extended bitmap sort itself requires a certain environment, just as the number above, and the meaning of the position number sequence number. Of course, we have seen the efficiency and excitingness of bitmap sorting. When we are sorted by our data, can you think about it: Analyze our data characteristics is critical, any problem may be a breakthrough from the analysis characteristics, consider that our data does not have a conversion method makes him Mapped to this digital relationship. The process of construct is also your creation. 5. Example () Cao Xihua 2005/04/15 This method comes from

转载请注明原文地址:https://www.9cbs.com/read-35624.html

New Post(0)