Question

Hello I have an automata question could you help me?

[1Points] Give a formal description of a Turing Machine M  that takes two parameters: an integer and an array of integers and decides whether the given integer is an
element of the array or not. You can assume that all the integers are between 0 and 9. The input string will be written on the tape of the Turing machine. The first square
of the tape contains the integer, the second square of the tape has the #  symbol, and the next n squares of the tape have the elements of the array. Your Turing machine
should accept the input string if the integer (written in the first square of the tape) is an element of the array, and it should reject otherwise. The array is NOT sorted.

[1 Point s] What is the worst case asymptotic time complexity of your algorithm? You should use almost everywhere analysis. Present your result in O(.) notation and justify
your answer.

[1 Point s] Let us now assume that the array given as the parameter is sorted. From the introduction to programming classes, you know that we can decide whether a given
integer is an element of a given sorted array or not in time O(logn) in modern computers, where n is the size of the array, by using the binary search algorithm. Is it possible to give a Turing Machine that solves the search problem on a sorted array in O(logn time?


O(logn
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Basic idea: Construct a small WB program for each state that simulates that state. ● Combine all programs together to get an overall WB program that simulates the Turing machine. A State in a Turing Machine ● There are three kinds of states in a Turing machine: ● Accepting states, ● Rejecting states, and ● “Working” states. ● We can easily build WB programs for the first two: // qacc 0: Accept // qrej 0: Reject Working States ● At a given working state in a Turing machine, we will do exactly the following, in this order: ● Read the current symbol. ● Write back a new symbol based on this choice of symbol. ● Transition to some destination state. ● (Infinitely long) Tape of 1’s and 0’s • Able to read and write the tape, and move the tape • Has initial state, instructions, halt state • Instructions define for each state and value: – What value to write? – Whether the tape should be moved, and in which direction?

M - Turing Machine (The program) ∑ - Alphabet of Turing Machine x - String at which M begins (Input) Turing Machines M - Turing Machine (The program) ∑ - Alphabet of Turing Machine x - String at which M begins (Input) y – String at which M halts (Output) Turing Machines M - Turing Machine (The program) ∑ - Alphabet of Turing Machine x - String at which M begins (Input) y – String at which M halts (Output) I.e. for each value of x, M computes a function such that: Turing Machines M - Turing Machine (The program) ∑ - Alphabet of Turing Machine x - String at which M begins (Input) y – String at which M halts (Output) I.e. for each value of x, M computes a function such that: f:∑*  ∑*

TIME COMPLEXITY:

Each program has a maximum runtime • The worst-case time complexity of an algorithm on an input of size n – maximum time taken Big-O Notation • Each program has a maximum runtime • The worst-case time complexity of an algorithm on an input of size n – maximum time taken • Big-O notation ignores exact runtimes for simplification Big-O Notation • Each program has a maximum runtime • The worst-case time complexity of an algorithm on an input of size n – maximum time taken • Big-O notation ignores exact runtimes for simplification • E.g. (7.25n^2 – 1.14n + 2.83)/2  O(n^2)

Add a comment
Know the answer?
Add Answer to:
Hello I have an automata question could you help me? [1Points] Give a formal description of a Tu...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this in JAVA. please help me. Thank you. In this project. you...

    I need help with this in JAVA. please help me. Thank you. In this project. you are given a unimodal array of n integer and your task is to find the maximum integer in the array in theta(logn) time. An unimodal array of integers is an array with entries that monotonically increase up to the maximum integer value and then monotonically decrease for the rest of the array. For example: (2, 5, 8, 9, 12, 15, 21, 17, 10, 4)...

  • You are given an array A of integers in sorted order. However, you do not know...

    You are given an array A of integers in sorted order. However, you do not know the length n of the array. Assume that in our programming language arrays are implemented in such a way that you receive an out-of-bounds error message whenever you wish to access an element A[i] with i>n. For simplicity we assume that the error message simply returns the value INT_MAX and that every value in the array is smaller than INT_MAX. (a) Design an algorithm...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

  • 1. Please write a Divide-and-Conquer Java algorithm solving the following problem: Given an "almost sorted" array...

    1. Please write a Divide-and-Conquer Java algorithm solving the following problem: Given an "almost sorted" array of distinct integers, and an integer x, return the index of x in the array. If the element x is not present in the array, return -1. "Almost sorted" means the following. Assume you had a sorted array A[0…N], and then split it into two pieces A[0…M] and A[M+1…N], and move the second piece upfront to get the following: A[M+1]…A[N]A[0]…A[M]. Thus, the "almost sorted"...

  • 4) [15 points total (5 points each)] Assume you are given a sorted array A of n numbers, where A is indexed from 1 up t...

    4) [15 points total (5 points each)] Assume you are given a sorted array A of n numbers, where A is indexed from 1 up to n, anda number num which we wish to insert into A, in the proper sorted position. The function Search finds the minimum index i such that num should be inserted into Ali]. It searches the array sequentially until it finds the location i. Another function MakeRoom moves A[i], .., AIn] to Ali+1]...AIn+1] same sort...

  • Hi, I have programming problem related to array, sorting, and. swap operation Thank you, Best Regards.....

    Hi, I have programming problem related to array, sorting, and. swap operation Thank you, Best Regards.. A non-empty array A consisting of N integers is given. You can perform a single swap operation in array A. This operation takes two indices I and J, such that 0 S13 J<N, and exchanges the values of A[i] and A[J]. The goal is to check whether array A can be sorted into non-decreasing order by performing at most one swap operation. For example,...

  • PLEASE IMPLEMENT YOUR SOLUTION RECURSIVELY IN C++. IT WOULD BE GREAT IF YOU COULD ALSO PROVIDE...

    PLEASE IMPLEMENT YOUR SOLUTION RECURSIVELY IN C++. IT WOULD BE GREAT IF YOU COULD ALSO PROVIDE TEST CODE FOR IT. 5) Design a recursive function to find the immediate successor of a target integer in an array o:f sorted integers. Here the immediate successor of a target is defined as the smallest number that is no smaller than the target in this sorted array int binarySuccessor(const int anArrayl, const int first, const int last, int target); In the above function...

  • You are going to implement Treesort algorithm in C++ to sort string data. Here are the...

    You are going to implement Treesort algorithm in C++ to sort string data. Here are the steps to complete the homework 1) Use the following class definition for binary search tree nodes. Its constructor is incomplete you should first complete the constructor. class TreeNode t public: string data; / this is the string stored in the node TreeNode left: TreeNode right; TreeNode (string element, TreeNode 1t, TreeNode rt //your code here 2) Write a function that will insert a string...

  • Subject: Algorithm need this urgent please thank you. 4. Give pseudocode for an algorithm that will solve the following problem. Given an array A[1..n) that contains every number between 1 and n +...

    Subject: Algorithm need this urgent please thank you. 4. Give pseudocode for an algorithm that will solve the following problem. Given an array A[1..n) that contains every number between 1 and n +1 in order, except that one of the numbers is missing. Find the miss sorted ing mber. Your algorithm should run in time (log n). (Hint: Modify Binary search). A pseudocode means an algorithm with if statements and loops, etc. Don't just write a paragraph. Also, if your...

  • Please help me with this question! If you could explain your answer and relate it to...

    Please help me with this question! If you could explain your answer and relate it to the HNMR shown on the right that would be great. Thanks! Draw the major product that results from the reaction below. Grignard, then condensation. HNMR is on the right with integrations in red. I'm pretty sure they're right this time. (2) MgBr We were unable to transcribe this image

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT