about | help | code help+videos | done | prefs |
makeEvenParity
When bits are sent across a network, they are sometimes corrupted by interference or errors. Adding some redundant bits to the end of the transmission can help to detect these errors. The simplest error detection algorithm is known as parity checking. A bit string has even parity if it has an even number of ones, and odd parity otherwise. In an even parity scheme, the sender adds a single bit to the end of the bit string so that the nal bit string has an even number of ones. For example, if we wished to send the data 1101011, would actually send 11010111 instead so that the bit string has an even number of ones. If we wished to send 1101001 instead, we would actually send 11010010. The receiver then checks whether the received bit string has even parity; if it does not, then an error must have occurred so it requests a retransmission. Write a function makeEvenParity(bits) that returns a string consisting of bits with one additional bit concatenated so that the returned string has even parity. Your function should call your evenParity function. For example, makeEvenParity('110101') should return '1101010' and makeEvenParity('110001') should return '1100011' makeEvenParity('110101') → '1101010' makeEvenParity('110001') → '1100011' makeEvenParity('0000') → '00000' ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy