Radix Sort Algorithm

前端 未结 4 1272
时光说笑
时光说笑 2021-01-14 07:39

I have been given some algorithms to reverse engineer. The algorithm below is a radix sort, but I am very confused about what is actually happening in the code.

I\'

4条回答
  •  耶瑟儿~
    2021-01-14 07:58

    A mask, or bitmask, is used to "turn off" every bit except those that are allowed to be "seen" through the mask. The 0s filter out the bit they are ANDed with, the 1s allow the bit through. A common usage is to isolate a byte-sized portion of an integer data type:

    00000000 11111111 00000000 00000000
    & // Boolean AND
    10010101 10010101 10010101 10010101
    yields
    00000000 10010101 00000000 00000000
    

提交回复
热议问题