1. Bit Map Introduction to the algorithm

So-called Bit-map Just use one bit Bit to mark the corresponding Value, and Key That's the element . Because of the adoption of Bit Store data in units , So in terms of storage space , Can save a lot .

2. Bit Map The basic idea of

Let's take a concrete example first , Suppose we want to be right 0-7 Internal 5 Elements (4,7,2,5,3) Sort （ Let's assume that these elements are not repeated ）. Then we can adopt Bit-map To achieve the purpose of sorting . To express 8 Number , We just need 8 individual Bit（1Bytes）, First we open up 1Byte Space , Put all of these spaces Bit All bits are set to 0, Here's the picture ：

And then go through this 5 Elements , The first element is 4, Then put 4 The corresponding position is 1（ You can do this p+(i/8)|(0x01<<(i%8)) Of course, the operation here involves Big-ending and Little-ending The situation of , I think so Big-ending）, Because it starts from scratch , So the fifth position is one （ Here's the picture ）：

And then deal with the second element 7, Put the eighth position at 1,, Then I'll deal with the third element , All the way to the end, all the elements , Set the corresponding position to 1, At this time of memory Bit The status of bits is as follows ：

And then we're going through it now Bit Area , Output the number of the one bit （2,3,4,5,7）, In this way, the purpose of sorting is achieved .

1. It's very efficient , No comparison or displacement ;

2. Less memory , such as N=10000000; Just use... Memory N/8=1250000Byte=1.25M.

shortcoming ：

All the data can't be repeated . That is, duplicate data cannot be sorted and searched .

3. Map The mapping table

Let's say the total number of items that need to be sorted or searched N=10000000, So we need to apply for the memory size of int a[1 + N/32], among ：a[0] In memory 32 To be able to correspond to a decimal number 0-31, By analogy ：

bitmap The table is ：

a[0]--------->0-31

a[1]--------->32-63

a[2]--------->64-95

a[3]--------->96-127

..........

So how to convert a decimal number to a corresponding bit position , The following describes the use of displacement to convert decimal numbers into corresponding bit position .

4. Displacement conversion

Apply for one int One dimensional array , Then it can be regarded as 32 Two dimensional array of bits ,

|            　　　　 32 position                    　　　　　　|

int a[0]    |0000000000000000000000000000000000000|

int a[1]    |0000000000000000000000000000000000000|

………………

int a[N]    |0000000000000000000000000000000000000|

For example, the decimal system 0, Corresponding to a[0] Occupied bit To be the first in the world ： 00000000000000000000000000000001

0-31： Corresponding to a[0] in

i =0                      00000000000000000000000000000000

temp=0                   00000000000000000000000000000000

i =1                      00000000000000000000000000000001

temp=1                   00000000000000000000000000000001

i =2                      00000000000000000000000000000010

temp=2                   00000000000000000000000000000010

i =30                     00000000000000000000000000011110

temp=30                  00000000000000000000000000011110

i =31                     　　　　　　　00000000000000000000000000011111

temp=31                  　　　　　　00000000000000000000000000011111

32-63： Corresponding to a[1] in

i =32                     00000000000000000000000000100000

temp=0                   00000000000000000000000000000000

i =33                     00000000000000000000000000100001

temp=1                   00000000000000000000000000000001

i =34                     00000000000000000000000000100010

temp=2                   00000000000000000000000000000010

i =61                       00000000000000000000000000111101

temp=29                    00000000000000000000000000011101

i =62                       00000000000000000000000000111110

temp=30                    00000000000000000000000000011110

i =63                       00000000000000000000000000111111

temp=31                    00000000000000000000000000011111

Analysis of the corresponding table above , three ：

1. Find decimal 0-N Corresponding to the array a Subscript in ：

Decimal system 0-31, Corresponding to a[0] in , Start with the decimal number n Convert to and from 32 The remainder of can be converted to the corresponding in the array a Subscript in . such as n=24, that n/32=0, be 24 Corresponding to the array a The subscript in is 0. And such as n=60, that n/32=1, be 60 Corresponding to the array a The subscript in is 1, In the same way, we can calculate 0-N In the array a Subscript in .

2. seek 0-N Corresponding 0-31 The number in ：

Decimal system 0-31 As the corresponding 0-31, and 32-63 Then it's the same thing 0-31, That is, given a number n You can go through the mold 32 Get the correspondence 0-31 The number in .

3. Using displacement 0-31 Make corresponding 32bit Position as 1:

To find the corresponding 0-31 The number is M, Move left M position ： namely 2^M. Then put 1.

From this we calculate 10000000 individual bit Occupied space ：

1byte = 8bit

1kb = 1024byte

1mb = 1024kb

The space occupied is ：10000000/8/1024/1024mb.

5. Expand

Bloom filter It's right bit-map An extension of

6. Bit-Map Application

1） Fast data search , Weight determination , Delete , Generally speaking, the data range is int Of 10 Below the times .

2） Data compression is achieved by removing duplicate data

7. Bit-Map The concrete realization of

``` #define BITSPERWORD 32
#define SHIFT 5
#define N 10000000

int a[ + N/BITSPERWORD];// Application memory size

//set  Set the bit Position as 1
void set(int i) {
}
//clr  Initialize all bit Position as 0
void clr(int i) {
}
//test  The test is in bit For whether it is 1
int  test(int i){
return a[i>>SHIFT] &   (<<(i & MASK));
}

int main()
{
int i;
for (i = ; i < N; i++)
clr(i);
while (scanf("%d", &i) != EOF)
set(i);
for (i = ; i < N; i++)
if (test(i))
printf("%d\n", i);
return ;
}  ```

Indicate the ： Move left n Bits are multiplied by 2 Of n Power , Move right n Bits are divided by 2 Of n Power

Analyze the void set(int i) {        a[i>>SHIFT] |=  (1<<(i & MASK)); }

1)  i>>SHIFT：

among SHIFT=5, namely i Move right 5 by ,2^5=32, amount to i/32, That is to find the decimal system i Corresponding to the array a Subscript in . such as i=20, adopt i>>SHIFT=20>>5=0 Obtainable i=20 The subscript of is 0;

among MASK=0X1F, Hexadecimal to decimal to 31, Binary for 0001 1111,i&（0001 1111） It's equivalent to keeping i After 5 position .

such as i=23, Binary for ：0001 0111, that

0001 0111

& 0001 1111 = 0001 0111 Decimal system ：23

such as i=83, Binary for ：0000 0000 0101 0011, that

0000 0000 0101 0011

& 0000 0000 0001 0000 = 0000 0000 0001 0011 Decimal system ：19

i & MASK amount to i%32.

Is equivalent to 1 Move left (i & MASK) position .

such as (i & MASK)=20, that i<<20 Equivalent to ：

0000 0000 0000 0000 0000 0000 0000 0001 << 20

=0000 0000 0001 0000 0000 0000 0000 0000

Note that the above “|=”. Bitwise operators and their applications I mentioned the application of bit operation ：

take int Type variable a Of the k Positional clarity 0, namely a=a&~(1<<k)

take int Type variable a Of the k Location 1, namely a=a|(1<<k)

Here will be   a[i/32] |= (1<<M)); The first M Location 1 .

4) void set(int i) { a[i>>SHIFT]  |=  (1<<(i & MASK)); } Equivalent void set(int i) {  a[i/32] |= (1<<(i%32));  }

That is to realize the three steps mentioned above ：

1. Find decimal 0-N Corresponding to the array a Subscript in ： n/32

2. seek 0-N Corresponding 0-31 The number in ： N%32=M

3. Using displacement 0-31 Make corresponding 32bit Position as 1: 1<<M, Juxtaposition 1;

Then print the results ：

0=11000000000000000000000000001110

1=1000001000000000000000010

6=10000000

32 Who said , The actual results are clear at a glance , have a look 1,2,3,30,31, 33,50,56,199 Where the data is located ：

31  30                                                       　　　　　　　3     2    1

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />                                                                           aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />

0=  1    1    00       0000   0000   0000   0000    0000   0000   1     1   1  0

56          50                                   33

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />          aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />                                   aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />

1= 0000  0001  0000  0100  0000  0000  0000  0010

199

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAIAAACJJmN7AAAByklEQVQokXXSzUvUURTG8fk3DYQiaCBoHzoTQaCm9kK5qZRZ1CYQEiyhgiBdFRFCC3tZFPkSqOgMjvO7955znm+LUUYnussDH865zzk1eoYHpUf0RElSDg6dLbg2tbDTwQMCLwDFjdNXIyjdHpHNjqrcNTjKdKH1dv3qxJO51nIxLFNShBCck54yslAySoYMvw6pTzwebdxvTi9sfN+TQBxndwa4JgdALqyK3DHvOnNPV56tbYxcn/34bX9idj4bKatyylmJCCG5Y51SJVj/ut240/oJF8bvduDBo+dv3n1wyJDPDFwL4dGPwDIcpHL7YWv1y/YPZ2RsZtfY3EuTM3PbuwcVpLM9i3AIvGdVhtVPnyfvzbfhN4w2p9uQYPHFyuLScoJqSBY3EUE5tur1+7Wd/dQONuHijam2yEGvsqWXr5Jk5xICEWBQnDAo4gi24FLjVheKAFzmMCwhoEARJoigJ/6Iy42bx+AKsFB24txW6DdUhgIGKEiwC1fGGz0UylAUSf9KUVBGuS9xitgT9eZ4kqMMiVM5uKFAkqOCMsRAQr05lk7qfcmwDCSKKCc1p4h9qDfH8ulHFLkvB9MaFEWEqX+H+q8cyvYv0jsfu2bQ+9kAAAAASUVORK5CYII=" alt="" />

6=  0000  0000  0000  0000  0000  0000  1000  0000

【 Problem instance 】

1) It is known that a file contains some phone numbers , Each number is 8 Digit number , Count the number of different numbers .8 Most bits 99 999 999, Probably need 99m individual bit, Probably 10 A few m Bytes of memory . （ Can be understood as from 0-99 999 999 The number of , Each number corresponds to one Bit position , So you just need to 99M individual Bit==1.2MBytes, such , Just a little 1.2M Left and right memory represents all 8 Number of phone numbers ）

2)2.5 The number of non repeated integers found in billion integers , There's not enough memory for this 2.5 Million integers . take bit-map Extend the , use 2bit Represent a number ,0 Indicates no ,1 Indicates one occurrence ,2 Appear 2 Times and above , In traversing these numbers , If the value of the corresponding position is 0, Set it to 1; If it is 1, Set it to 2; If it is 2, Keep the same . Or we don't 2bit To represent , We use two bit-map You can simulate this 2bit-map, It's the same thing .

``` // use char Array storage 2-Bitmap, Don't worry about the size of the memory
unsigned char flags[]; // Array size customization
unsigned get_val(int idx)  {
//  |    8 bit  |
//  |00 00 00 00|  // mapping 3 2 1 0
//  |00 00 00 00|  // Express 7 6 5 4
//  ……
//  |00 00 00 00|

int i = idx/;  // One char  Express 4 Number ,
int j = idx%;
unsigned ret = (flags[i]&(0x3<<(*j)))>>(*j);
//0x3 yes 0011 j For the range of 0-3, therefore 0x3<<(2*j) The scope is 00000011 To 11000000  Such as idx=7 i=1 ,j=3  that flags[1]&11000000,  Get is |00 00 00 00|
// Express 7 6 5 4
return ret;
}

unsigned set_val(int idx, unsigned int val)  {
int i = idx/;
int j = idx%;
unsigned tmp = (flags[i]&~((0x3<<(*j))&0xff)) | (((val%)<<(*j))&0xff);
flags[i] = tmp;
return ;
}
{
if (get_val(idx)>=) {  // This position has already appeared ？？
return ;
}  else  {
set_val(idx, get_val(idx)+);
return ;
}
}

// Only test for non negative numbers ;
// If you think about negative numbers , One more 2-Bitmap Array .
int a[]={, , , , , , , , , , , ,, , ,,,,,,};

int main()   {
int i;
memset(flags, , sizeof(flags));

printf(" The original array is :");
for(i=;i < sizeof(a)/sizeof(int); ++i)  {
printf("%d  ", a[i]);
}
printf("\r\n");
printf(" Numbers that only appear once :");
for(i=;i < ; ++i)  {
if(get_val(i) == )
printf("%d  ", i);
}
printf("\r\n");

return ;
}  ```

## Big data processing -bitmap It's a more related article about Shenma things

1. Big data processing -Bitmap

MapReduce It's a programming model , For large data sets ( Greater than 1TB) Parallel operation of . Concept "Map( mapping )" and "Reduce( reduction )" Bit-map Space compression and quick sort to ...

2. function : Recursion is a magic horse - Basic learning Python022

function : Recursion is a magic horse Let programming change the world Change the world by program The theme of our class is recursion, which is Shenma , Will be through the small turtle with a sense of explanation , To tell you that Shenma is recursive ! If a good programmer is Bole , Then give me ...

3. Basic learning Python（22）-- function ： Recursion is a magic horse

Knowledge point Recursion is a magic horse ? Recursion belongs to the category of algorithms . Recursion is a behavior of a function call itself . >>> def g(): return g() >>> g() Traceback ...

4. Magic Horse ,EntityFramework Core 1.1 Updated again ？ go , Hurry to watch

Preface Oh , Don't do SQL Why? , Of course it will continue , It will continue to update over the weekend , It is estimated that there will be dozens of articles to be finished , But I will insist on SQL Updated completely , It's not going to be bad , If it hasn't been updated for a long time , Don't miss me , That means I'm learning new skills , That's learning English , Ben ...

5. SQLSERVER It's something you see all the time CACHE STORES It's Shenma Dongdong ？

SQLSERVER It's something you see all the time CACHE STORES It's Shenma Dongdong ? When we're in SSMS Do the following SQL Statement empty SQLSERVER When you're caching , We will be in SQL ERRORLOG I see some information in the library DBCC ...

6. Record a database tuning process （IIS Send to me SQLSERVER Of FETCH API_CURSOR Sentence is god horse ？）

Record a database tuning process (IIS Send to me SQLSERVER Of FETCH API_CURSOR Sentence is god horse ?) A few days ago, I helped customers optimize a database , The size of that database is 6G It's reasonable that such a small database won't have too much performance problems , ...

7. [ Re posting ]Tensor What is god horse? ？ Why would Flow?

Tensor What is god horse? ? Why would Flow? Internet enthusiasts There was no. 17-05-2310:03 Big data digest works , Please refer to the end of the article for reprint requirements compile | Shao Pangpang , Jiang Fan , Da Jieqiong ,Aileen Maybe you've downloaded TensorFl ...

8. Big data processing framework Strom: Storm----helloword

Big data processing framework Strom: Storm----helloword Storm Run according to the designed topology flow , So before you write the code, you need to design the topology . Here's a simple topology : First step : Create a topology class that contains main Methodical ...

9. Baidu , Google ,360, sogou , God horse and other spiders IP paragraph

https://www.imydl.com/wzjs/5971.html Remember 3 In January, Mingyue shared an article [ Stationmaster must : Baidu . Google . sogou .360 When spiders are common IP Address ] The article , Seems to have been the attention of many webmasters ...

## Random recommendation

1. js Kuzhi dojo

Use dojo Source code 1. download Dojo 2.dojo The directory structure is as follows demo/ myModule.js dojo/ dijit/ dojox/ util/ hellodojo.html 3. introduce dojo. ...

2. [Hadoop big data ]——Hive Getting started with deployment

Hive To solve the problem hadoop in mapreduce Write the difficult , To be familiar with sql Of people who use . As long as you are right SQL Have some understanding , You can pass Hive Write mapreduce The program , Instead of learning hadoop Medium api. ...

3. LINQ to SQL sentence (16) Object identification of

Object identifier Objects in the runtime have unique identities . Two variables that refer to the same object actually refer to the same instance of the object . When you change a variable , You can see these changes through another variable . Rows in relational database tables do not have unique identities . Because each line has a unique main ...

4. Eight queens , Backtracking and recursion （Python Realization ）

The eight queens problem is a famous mathematician Gauss in the 19th century 1850 in . The following is a python Statement of the eight queens code , Excerpt from <Python Basic course >, Code relative to other languages , It's short and can be printed at one time 92 Seed result . At the same time, it can expand ...

5. Linux Lower serial port ttyS2,ttyS3 Solutions to problems that don't work

PC104,Xlinux Next , Suddenly found the serial port 3,4 Out-of-service ... Thought it was a hardware problem , Switch to wince after ,3,4 Work well , Eliminate circuit problems stay linux Check out dmesg: serial8250: ttyS0 at ...

6. etcd Use it ttl The problem of inaccuracy

Problem phenomenon Deployment has a etcd colony , Namely 10.8.65.106,10.8.65.107 and 10.8.65.108. And then I use etcdctl Set... For a value ttl, And then through watch Observe , It is found that the failure time is not accurate ...

7. 【BZOj 3670】【UOJ #5】【NOI 2014】 zoo

http://www.lydsy.com/JudgeOnline/problem.php?id=3670 http://uoj.ac/problem/5 You can build "KMP automata " however ...

8. Stream- Quick start Stream Programming

1. What is flow Stream Not a collection element , It's not a data structure and doesn't hold data , It's about algorithms and calculations , It's more like an advanced version of Iterator. Original version of Iterator, Users can only explicitly traverse elements one by one and execute ...

9. Begin to learn .net The second day of the

There is no class this morning for some reason . I went to school in the afternoon .net Table for . <body></body><img src="../temp/ New folder /64aab4ae3e632dbc ...

10. Object oriented design pattern _ Generator mode interpretation (Builder Pattern)

First of all, it is easy to think of an application scenario : The production process of mobile phones : Mobile phones have a lot of sub components ( parts ), Tens of thousands of , The production process of different brands of mobile phones is complex and different , The design of mobile phones of the same brand is also diversified due to the needs of customers , It's as big as the model , Small to color , whether ...