EPI 4.1 Computing The Parity Of A Word In Python - Version 4
We are looking at question 4.1 from Elements Of Programming Interviews Book. How to compute parity of binary word version 4 using CPU's word level XOR instructions.
If you are applying for software engineering positions I highly recommend getting this book.
How to compute parity of binary word version 4 using CPU's word level XOR instructions.
The parity of a binary word is 1 if the number of 1s i n the word is odd; otherwise, it is 0. For example, the parity of 1011 is 1, and the parity of 1000010000 is 0. Parity checks are used to detect single bit errors in data storage and communication. It is fairly straight forward to write code that computes the parity of a single 64-bit word.
Here is the video I created which walk you through solution provided in the book.