After converting a number to its binary form, replace every one of the number with 0 and every 0 with 1, then the resulting number will be known as 1, s compliment of that binary number.
Input-1 : 101010 Output-1 : 010101 Input-2 : 1110100 Output-2 : 0001011
- First make a initial state.
- Then convert each 0 to 1 and each 1 to 0, and reach to next possible state.
- after performing step 2 on each digit of binary number, reach at some final state to complete the process.
Design Mealy Machine :
Take a initial state say q1, and if the input is found 0, convert it to 1, remain at same state and check for another input alphabet.
If state q1 takes input alphabet is 1, then convert it to 0 and remain at same state.
Step-3:As after converting all alphabet, it is on same state then this state will be final state as well.
Suppose a string 10001 and start parsing from left to right. Every 0 will be replaced by 1 and every one is replaces by 0. Then the output is 01110.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.