- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Draw a Turing machine to find 2’s complement of a binary number
2’s complement of binary numbers can be done by using two approaches.
Adding 1’s complement+1
Traverse bits from left to right, find the 1st 1 bit then reverse all the bits after the 1 bit.
Let the input be 1110010
Thus, after performing 2’s complement, the output will be as follows −
Output − 0001110
Coming to the Turing machine to find 2’s complement,
If input is as follows −
The output is as follows −
Step 1 − Here, we need to start from the rightmost ends.
Step 2 − We will move the R/W head all the way to the right, skipping all the 0s and 1s.
Step 3 − On moving right, when we end up on the blank B, then move one step to the left.
Step 4 − Then we will move the R/W head to the left skipping all the 0s.
Step 5 − When it reaches a 1, then we will skip this 1, and then move one step left.
Step 6 − From now, we will make all the 1s to 0s and 0s to 1s.
Step 7 − We will repeat it all the way to the left of the string.
Step 8 − On moving all the way to the left, we will reach the blank B,
Step 9 − then move one step right, such that the R/W head will point to the first character, then we will stop.
The corresponding Turing machine (TM) is shown below. Here Q0 is the initial state and Q3 is the final state.
With the help of state ‘q0’ we can reach the end of the string, whenever BLANK is reached then move towards left.
With the help of state ‘q1’ we can pass all 0’s and move left first 1 is found.
Pass single ‘1’ and then move left.
With the help of state ‘q2’ we can complement each digit and move left, whenever BLANK is reached then move towards right and reach the final state q2.
- Draw a Turing machine to find 1’s complement of a binary number
- Design a Moore machine to generate 1's complement of a binary number.
- 1’s and 2’s complement of a Binary Number?
- Construct a Turing machine for adding 2 to the binary natural number?
- 10’s Complement of a decimal number?
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 1's and 2's complement of 16-bit number
- Give implementation-level descriptions of a Turing machine?
- 1's Complement vs 2's Complement
- Explain about a non-deterministic Turing Machine?
- 2's complement notation
- 2's complement fractions
- Haskell Program to find the 1's complement of the given number
- Swift Program to find the 1's complement of the given number
- Design Turing machine for multiplication