Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 555441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:48:54+00:00 2026-05-13T11:48:54+00:00

Are they any helpful guidelines to describing what a Turing machine does if you

  • 0

Are they any helpful guidelines to describing what a Turing machine does if you already have the pseudo code for the algorithm?

I’m taking a course on complexity theory and it takes me a while to describe a Turing machine that decides or accepts some language (states, transitions, etc.) even though I know how I could code it in something like C or even assembly. I guess I just haven’t had enough practice with Turing machines (working on it), but I appreciate any suggestions.

edit

I don’t want to make a Turing Machine simulator, I want to describe a Turing Machine on paper (alphabet, states, transitions) for deciding some language.

Here’s a trivial example of what I mean, say I need to write a Turing Machine that goes over a string of 0s and 1s and changes all the 0s in it to 1s. For example, if you start with 11010 on the tape (input) it halts with 11111 on the tape (output). Now in a high level language you know it’s something like:

Go over every character on tape
    If character is 0 change it to 1

The Turing machine description is informally something like:

You have two states, q and halt. When
you are on state q and you see a 1, go
to the right without changing it. If
you see a 0, change it to 1 and go to
the right. If you see the blank symbol
(end of tape) then go to the halt
state.

Formally you will have something like {q, halt} for states. {((q, 1) -> (q, 1, R)), ((q, 0) -> (q, 1, R)), ((q, #) -> (halt, 0, L))} for transitions.

Now this problem is trivial, but there are others which are more involving (add unary numbers or recognize a language with equal number of a’s, b’s, and c’s). I could easily write the pseudocode for them, but writing the Turing Machine is far more challenging (takes me a long time) and I was wondering if there were some tips, resources, or guidelines that help me become better at solving problems like that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:48:54+00:00Added an answer on May 13, 2026 at 11:48 am

    Disclaimer: Your question is very general, hence so is this answer. Note that I’m anything but an expert on TMs, and
    this approach will usually not be very efficient (I can’t even promise it will always be effective).
    I’m just jotting down some thoughts here.

    I would suggest trying an approach like this: Take your pseudo-code and reduce it so that
    it only consists of a) boolean variables and b) if-statements.
    For example:

    if THIS_LETTER_IS("A"):
        found_an_even_number_of_A = not found_an_even_number_of_A
    
    if THIS_LETTER_IS("Q") and previous_letter_was_X and found_an_even_number_of_A
            and not checking_for_alternative_2:
        # can't be a word of alternative 1, so check for alternative 2
        going_back_to_start_to_check_for_alternative_2 = True
    
    if going_back_to_start_to_check_for_alternative_2:
        MOVE_TO_PREVIOUS
    else:
        MOVE_TO_NEXT
    
    if going_back_to_start_to_check_for_alternative_2 and THIS_LETTER_IS(EMPTY):
        # reached the beginning, so let's check for alternative 2
        going_back_to_start_to_check_for_alternative_2 = False
        checking_for_alternative_2 = True
    

    When you have nested ifs, replace them with ands; remove else blocks by using not:

    if something:
        if something_else:
            do_a
        else:
            do_b
    

    becomes

    if something and something_else:
        do_a
    
    if something and not something_else:
        do_b
    

    Each if block should then only contain one MOVE_TO_PREVIOUS or MOVE_TO_NEXT, possibly a WRITE command and any number
    of variable assignments.

    Complete all if clauses such that every single one of your booleans AND the current letter is always checked, duplicating
    the blocks where neccessary. Example:

    if something and something_else:
        do_a
    

    becomes

    if THIS_LETTER_IS("A") and something and something_else and something_i_dont_care_about_here:
        do_a
    
    if THIS_LETTER_IS("A") and something and something_else and not something_i_dont_care_about_here:
        do_a
    
    if THIS_LETTER_IS("Q") and something and something_else and something_i_dont_care_about_here:
        do_a
    
    if THIS_LETTER_IS("Q") and something and something_else and not something_i_dont_care_about_here:
        do_a
    

    Now, if you have n booleans and m letters, you should have m * 2n ifs.
    Just imagine you have stored the booleans in a bitfield, so each possible combination of booleans represents an
    integer. Hence the above becomes

    if THIS_LETTER_IS("A") and bitfield[0] and bitfield[1] and bitfield[2]:
        do_a
    
    if THIS_LETTER_IS("A") and bitfield[0] and bitfield[1] and not bitfield[2]:
        do_a
    
    # ...
    

    which then becomes

    if THIS_LETTER_IS("A") and bitfield == 7:
        do_a
    
    if THIS_LETTER_IS("A") and bitfield == 3:
        do_a
    
    # ...
    

    This integer value for the bitfield is the Turing machine state. The do_a part is just an assignment to the booleans (i.e. the bitfield, so it’s your new state), a write command (if there’s none, just write the letter that was already
    there) and a movement command, hence explicitly a Turing Machine transition.

    I hope any of the above makes sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.