Hello!! Comrades, tell me, please, how to make a search for a specific combination in a BIT array, for example, such a 01111110
?
- describe the task in more detail - DreamChild
|
1 answer
Since you can easily index bits by number, the task comes down to finding a substring for which there are many well-known algorithms .
If you simply, try scanning an array of pieces of size (l + 7)
bits, rounded to a whole number of bytes (i.e., (l + 7 + 7) / 8 == (l + 14) / 8
), starting with each byte, and look for your string with all possible shifts from 0 to 7. l
is the bit length of the search string:
01001011 11110011 11111101 00111110
one)
11111101 00111110
compare with
01111110 0 1111110 01 111110 011 11110 0111 1110 01111 110 011111 10 0111111 0
2)
11110011 11111101
compare with
01111110 0 1111110 01 111110 011 11110 0111 1110 01111 110 011111 10 0111111 0
etc.
- With mathematics, everything is clear and transparent, I cannot implement this search in the code !! - IGOR
- oneShow at least what you managed to do. - Shad
- There, I read the two lines of the binary into an array, translate it into BitArray, you need to find the sync pattern position in it and copy it from the position found to the next sync pattern position into another array and into the file. - IGOR
- @IGOR: Well, what happens next? Describe which algorithm you chose. - VladD
|