The Wayback Machine - https://web.archive.org/web/20240620132417/https://www.geeksforgeeks.org/turing-machine-for-subtraction/
Open In App

Turing machine for subtraction | Set 1

Last Updated : 12 May, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – Turing Machine Problem-1: Draw a Turing machine which subtract two numbers. Example: Steps:

  • Step-1. If 0 found convert 0 into X and go right then convert all 0’s into 0’s and go right.
  • Step-2. Then convert C into C and go right then convert all X into X and go right.
  • Step-3. Then convert 0 into X and go left then convert all X into X and go left.
  • Step-4. Then convert C into C and go left then convert all 0’s into 0’s and go left then convert all X into X and go right and repeat the whole process.
  • Step-5. Otherwise if C found convert C into C and go right then convert all X into B and go right then convert 0 into 0 and go left and then stop the machine.

Here, q0 shows the initial state and q1, q2, q3, q4, q5are the transition states and q6shows the final state. And X, 0, C are the variables used for subtraction and R, L shows right and left. Problem-2: Draw a Turing machine which subtract two numbers m and n, where m is greater than n. Steps:

  • Step-1. If 0 found convert all 0’s into 0’s and go right then convert C into C and go right
  • Step-2. If X found then convert all X into X and go right or if 0 found then convert 0 into X and go left and go to next step otherwise go to 5th step
  • Step-3. Then convert all X into X and go left then convert C into C and go left
  • Step-4. Then convert all 0’s into 0’s and go left then convert B into B and go right then convert 0 into B and go right and repeat the whole process
  • Step-5. Otherwise if B found convert B into B and go left then convert all X into B and go left then convert C into B and go left and then stop the machine.

Here, q0 shows the initial state and q1, q2, q3, q4, q5are the transition states and q6shows the final state. And B, X, 0, C are the variables used for subtraction(m>n) and R, L shows right and left and B variable is a input symbol. See for – Turing Machine for subtraction | Set 2


Previous Article
Next Article

Similar Reads

Turing Machine for subtraction | Set 2
Prerequisite – Turing Machine, Turing machine for subtraction | Set 1 A number is represented in binary format in different finite automatas like 5 is represented as (101) but in case of subtraction Turing Machine unary format is followed . In unary format a number is represented by either all ones or all zeros. For example, 5 will be represented b
2 min read
Turing machine for multiplication
Prerequisite - Turing Machine Problem: Draw a turing machine which multiply two numbers. Example: Steps: Step-1. First ignore 0's, C and go to right & then if B found convert it into C and go to left. Step-2. Then ignore 0's and go left & then convert C into C and go right. Step-3. Then convert all X into X and go right if 0 found convert i
2 min read
Turing machine for copying data
Prerequisite - Turing Machine Problem - Draw a Turing machine which copy data. Example - Steps: Step-1. First convert all 0's, 1's into 0's, 1's and go right then B into C and go left Step-2. Then convert all 0's, 1's into 0's, 1's and go left then Step-3. If 1 convert it into X and go right convert all 0's, 1's into 0's, 1's and go right then conv
2 min read
Why only subtraction of addresses allowed and not division/addition/multiplication
Why Subtraction is allowed? Two addresses can be subtracted because the memory between the two addresses will be valid memory. Let's assume memory Ptr_1 and ptr_2 valid addresses. It is obvious that memory between these two addresses is valid. Pointer ptr_1 is pointing to 0x1cb0010 memory location and ptr_2 is pointing to 0x1cb0030 memory location.
2 min read
Virtualization | A Machine Reference Model
Prerequisite: Introduction to Virtualization When an execution environment is virtualized at unlike levels of the stack of computation then it requires a reference model which defines the interfaces within the level of abstractions, and this level of abstraction hides the details of implementations. This projects an idea that, virtualization techni
3 min read
Relationship between Data Mining and Machine Learning
There is no universal agreement on what "Data Mining" suggests that. The focus on the prediction of data is not always right with machine learning, although the emphasis on the discovery of properties of data can be undoubtedly applied to Data Mining always. So, let's begin with that: data processing may be a cross-disciplinary field that focuses o
3 min read
Create Free Windows Virtual Machine in Azure
A virtual machine may be a file, typically called an image, which behaves like an actual computer. The top user has an equivalent experience on a virtual machine as they might have on dedicated hardware. But in a cloud virtual machine is an operating system image running on the server, we can use a cloud virtual machine in many ways - Development,
2 min read
Print Binary Tree levels in sorted order | Set 2 (Using set)
Given a tree, print the level order traversal in sorted order. Examples : Input : 7 / \ 6 5 / \ / \ 4 3 2 1 Output : 7 5 6 1 2 3 4 Input : 7 / \ 16 1 / \ 4 13 Output : 7 1 16 4 13 We have discussed a priority queue based solution in below post.Print Binary Tree levels in sorted order | Set 1 (Using Priority Queue) In this post, a set (which is impl
5 min read
Check whether the number has only first and last bits set | Set 2
Given a positive integer n, check whether only the first and last bits are set in the binary representation of n. Print 'Yes' or 'No'.Examples: Input: 9 Output: Yes (9)10 = (1001)2, only the first and last bits are set. Input: 15 Output: No (15)10 = (1111)2, except first and last there are other bits also which are set. We have already discussed a
4 min read
Frequent Item set in Data set (Association Rule Mining)
INTRODUCTION:Frequent item sets, also known as association rules, are a fundamental concept in association rule mining, which is a technique used in data mining to discover relationships between items in a dataset. The goal of association rule mining is to identify relationships between items in a dataset that occur frequently together.A frequent i
6 min read
Article Tags :
Practice Tags :