Turing Machine design:
Assume the input is an integer N given as a binary string.
Also, assume head is placed at left most symbol of the input string and initial state is q0.
Step 1: Check the current symbol, if it is 1 replace it by X and change the state to q1. move to right until a 0 is found or a blank is found. If a blank is found in q0 means that there are equal number of 1’s and equal number of 0’s. Thus, go to step 7.
Step 2: If a 0 is found, replace it by Y and change state to q3. Move to extreme left. If blank is found change to state q0(continue from step1).
Step 3: otherwise, if a blank is found means that there are extra 1’s. Thus, change the state to q5 and move to extreme left. While moving change any symbol to blank(_). If left blank is found, write a 1 (i.e., number of 1’s > number 0’s) and change the state to qHALT.
Step 4: Check the current symbol, if it is 0 replace it by Y and change the state to q2. move to right until a 1 is found or a blank is found.
Step 5: If a 1 is found, replace it by X and change state to q4. Move to extreme left. If blank is found change to state q0(continue from step1).
Step 6: otherwise, if blank is found means that there are extra 0’s. Thus, change the state to q6 and move to extreme left. While moving change any symbol to blank(_). If left blank is found, write a 0 (i.e., number of 0’s > number 1’s) and change the state to qHALT.
Step 7: Move to extreme right. While moving, replace Xs with 1s and Ys with 0s(i.e., writing N )
If a black is found, change the state to qHALT.
The required Program (set of instructions) for the given Turning Machine that outputs according to given instructions, is as follows:
(q0 1 X R q1)
(q0 0 Y R q2)
(q0 X * R q0)
(q0 Y * R q0)
(q0 _ * L q7)
(q1 0 Y L q3)
(q1 1 * R q1)
(q1 X * R q1)
(q1 Y * R q1)
(q1 _ * L q5)
(q2 1 X L q4)
(q2 0 * R q2)
(q2 X * R q2)
(q2 Y * R q2)
(q2 _ * L q6)
(q3 * * L q3)
(q3 _ * R q0)
(q4 * * L q4)
(q4 _ * R q0)
(q5 * _ L q5)
(q5 _ 0 R qHALT)
(q6 * _ L q5)
(q6 _ 1 R qHALT)
(q7 X 1 R q7)
(q7 Y 0 R q7)
(q7 _ * * qHALT)
State diagram:
02-) Given a string from the language L(0+1) on the tape, give the program and draw...
rarisition written in the format of the Turing Machine simulator is a special state H which means halt. For the given Below is a Turing machine program where each line is a transition writen current state, read symbol, new state, write symbol, drection e-d. wmeans to state 4, write a 1 and move the tape head left. Notc there is a special state a os on the leftmost n nanks , write the resulting bitstring when the TM reaches the...
1. Fill out the following blanks for the instructions of a Turing machine that would move an input string over (a, b) to the right one cell position. The tape head initially is at the left end of the input string. The rest of the tape cells are blank. The machine will move the entire string to the right one cell position and leave all remaining tape cells blank. The tape head ends at the right end of the output...
1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...
Create a program that performs the following operations: 1. Prompt for and accept a string of up to 80 characters from the user. • The memory buffer for this string is created by: buffer: .space 80 #create space for string input The syscall to place input into the buffer looks like: li $v0,8 # code for syscall read_string la $a0, buffer #tell syscall where the buffer is li $a1, 80 # tell syscall how big the buffer is syscall 2....
Code to be written in C++: Initially, you will be given symbols printed in a preorder traversal of a boolean expression tree. The internal nodes of the tree will contain one of the following operators: & (and), | (or), ^ (exclusive-or), or ! (not). The nodes containing the first three operators will have two children, while the nodes containing the ! operator will contain only a left child. The leaves of the tree will contain an operand - either f...
In this assignment, you will write one (1) medium size C program. The program needs to be structured using multiple functions, i.e., you are required to organize your code into distinct logical units. The following set of instructions provide the specific requirements for the program. Make sure to test thoroughly before submitting. Write a program, named program1.c, that reads and processes employee records (data about an employee). Each employee record must be stored using a struct that contains the following ...
Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...
JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named problem1. 2. Create a Java class named StringParser with the following: ApublicstaticmethodnamedfindIntegerthattakesaStringandtwocharvariables as parameters (in that order) and does not return anything. The method should find and print the integer value that is located in between the two characters. You can assume that the second char parameter will always follow the firstchar parameter. However, you cannot assume that the parameters will be different from...
i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...
- Complete the code to solve a maze- Discuss related data structures topicsProgramming-----------In this part, you will complete the code to solve a maze.Begin with the "solveMaze.py" starter file.This file contains comment instructions that tell you where to add your code.Each maze resides in a text file (with a .txt extension).The following symbols are used in the mazes:BARRIER = '-' # barrierFINISH = 'F' # finish (goal)OPEN = 'O' # open stepSTART = 'S' # start stepVISITED = '#' #...