• Home
  • Textbooks
  • Invitation to Computer Science
  • Models of Computation

Invitation to Computer Science

G.Michael Schneider, Judith Gersting

Chapter 12

Models of Computation - all with Video Answers

Educators


Chapter Questions

01:10

Problem 1

Describe what factors might be included in a model for the spread of an epidemic.

Emily Terlap
Emily Terlap
Numerade Educator
01:58

Problem 2

Say an automobile manufacturer designs a new car using a sophisticated and detailed computer simulation, but no prototype vehicles, and the automobile is later found to have a defect. Do you think the manufacturer is accountable? Is the manufacturer accountable if it builds prototypes that do not reveal the defect, but it does not do a simulation?

Jennifer Stoner
Jennifer Stoner
Numerade Educator
01:45

Problem 3

Give an example of a potential use of computerized models in
a. The pharmaceutical industry
b. The food processing industry
c. The insurance industry

Ameer Said
Ameer Said
Numerade Educator

Problem 4

Which of the following can be considered computing agents and why?
a. A clock radio
b. A vacuum cleaner
c. A video camera
d. A programmable calculator

Check back soon!

Problem 5

Which of the following can be considered computing agents and why?
a. A clock radio
b. A vacuum cleaner
c. A video camera
d. A programmable calculator

Check back soon!

Problem 6

A Turing machine contains only the following instructions:
$$
\begin{aligned}
& (1,1,1,1, R) \\
& (1,0,1,2, R)
\end{aligned}
$$
Can this machine ever reach the following configuration? Explain your answer.
$$
.0016 \ldots
$$

Check back soon!

Problem 7

Is the following a legitimate Turing machine? Why or why not?
$$
\begin{aligned}
& (1,1,0,2, R) \\
& (1,0,0,3, R) \\
& (2,1,1,2, R) \\
& (3,0,0,3, R) \\
& (2,0,0,4, L) \\
& (3,0,1,4, L) \\
& (4,1,1,5, R) \\
& (4,0,0,5, R)
\end{aligned}
$$

Check back soon!

Problem 8

Find the output for the Turing machine
$$
\begin{aligned}
& (1,1,1,2, R) \\
& (1,0,0,2, R) \\
& (1, b, 1,2, R) \\
& (2,0,0,2, R) \\
& (2,1,0,1, R)
\end{aligned}
$$
when run on the tape
$$
\ldots b 1001 b \ldots
$$

Check back soon!

Problem 9

Find the output for the Turing machine
$$
\begin{aligned}
& (1,1,1,2, L) \\
& (2, b, 0,3, L) \\
& (3, b, 1,4, R) \\
& (4,0,1,4, R)
\end{aligned}
$$
when run on the tape
$$
\ldots b 1 b \ldots
$$

Check back soon!
02:01

Problem 10

Describe the behavior of the Turing machine
$$
\begin{aligned}
& (1,1,1,2, R) \\
& (2,0,0,1, L)
\end{aligned}
$$
when run on the tape
$$
\ldots .01016 \ldots
$$

Jennifer Stoner
Jennifer Stoner
Numerade Educator
05:22

Problem 11

Describe the behavior of the Turing machine
$$
\begin{aligned}
& (1,1,1,1, R) \\
& (1,0,0,2, L) \\
& (2,1,0,2, L) \\
& (2, b, 1,3, L) \\
& (3, b, b, 1, R)
\end{aligned}
$$
when run on the tape
$$
\ldots 01016 \ldots
$$

Chris Trentman
Chris Trentman
Numerade Educator
05:22

Problem 12

Describe the behavior of the following Turing machine on any input tape containing a binary string:
$$
\begin{aligned}
& (1,1,1,1, R) \\
& (1,0,0,1, R) \\
& (1,0,1,1, R)
\end{aligned}
$$

Chris Trentman
Chris Trentman
Numerade Educator
04:12

Problem 13

Write a Turing machine that, when run on the tape ...b11111b... produces an output tape of b01111b...
You can accomplish this using only one instruction.

Chris Trentman
Chris Trentman
Numerade Educator
09:20

Problem 14

Say a Turing machine is supposed to change any string of $1 \mathrm{~s}$ to a string of 0 s. For example,
...b111b...
should become
... b000b...
Will the following Turing machine do the job? Why or why not?
$$
\begin{aligned}
& (1,1,0,2, R) \\
& (2,1,0,3, R) \\
& (3,1,0,4, R)
\end{aligned}
$$

Chris Trentman
Chris Trentman
Numerade Educator
04:12

Problem 15

a. Write a Turing machine that, when run on the tape
b11111b...
produces an output tape of b11110b...
b. Write a Turing machine that, when run on any tape containing a unary string, changes the rightmost 1 to 0 and then halts. (If your solution to Exercise 15 a was sufficiently general, you will not have to change it here.)

Chris Trentman
Chris Trentman
Numerade Educator
15:22

Problem 16

Write a Turing machine to perform a unary decrement(the opposite of an increment). Assume that $n>0$.

Chris Trentman
Chris Trentman
Numerade Educator
15:22

Problem 17

Write a Turing machine to perform a unary decrement. Assume that $n$ may be 0 , in which case a single 0 should be output on the tape to signify that the operation results in a negative number.

Chris Trentman
Chris Trentman
Numerade Educator
04:12

Problem 18

Write a Turing machine that operates on any binary string and changes it to a string of the same length with all 1s. It should, for example, change the tape to
b011010b...
to
b111111 b...
However, you must write instructions that allow your Turing machine to work on any binary string, not just the one shown here.

Chris Trentman
Chris Trentman
Numerade Educator
04:59

Problem 19

Write a Turing machine that operates on any strin of $1 \mathrm{~s}$ and changes it to a string of alternating $1 \mathrm{~s}$ and $0 \mathrm{~s}$.

Chris Trentman
Chris Trentman
Numerade Educator

Problem 20

The parity-bit Turing machine of Section 12.5 .2 uses an odd parity bit scheme. Write a Turing machine that uses an even parity bit scheme.

Check back soon!
08:08

Problem 21

Write a Turing machine that efficiently adds 3 to any unary number.

Chris Trentman
Chris Trentman
Numerade Educator
07:50

Problem 22

Write a Turing machine that begins on a tape containing a single 1 and never halts but successively displays the strings
$$
\begin{array}{r}
. .616 \ldots \\
\text {... b010b... } \\
\text { bo0100b... }
\end{array}
$$
and so on.

Chris Trentman
Chris Trentman
Numerade Educator
05:34

Problem 23

Write a Turing machine that operates on the unary representation of any number and decides whether the number is 0 ; your machine should produce an output tape containing the unary representation of 1 if the number was 0 and the unary representation of 2 if the number was not 0 .

Chris Trentman
Chris Trentman
Numerade Educator
03:40

Problem 24

Write a Turing machine that takes any unary string of an even number of $1 \mathrm{~s}$ and halts with the first half of the string changed to 0 s. (Hint: You may need to use a "marker" symbol such as $X$ or $Y$ to replace temporarily any input symbols you have already processed and do not want to process again; at the end, your program must "clean up" any marker symbols.)

Chris Trentman
Chris Trentman
Numerade Educator
07:50

Problem 25

Write a Turing machine that takes as input the unary representation of any two different numbers, separated by a blank, and halts with the representation of the larger of the two numbers on the tape. (Hint: You may need to use a "marker" symbol such as $X$ or $Y$ to replace temporarily any input symbols you have already processed and do not want to process again; at the end, your program must "clean up" any marker symbols.)

Chris Trentman
Chris Trentman
Numerade Educator
04:59

Problem 26

The Turing machine described in Section 12.5 .4 to add two unary numbers was designed to erase the two leftmost is on the tape, move to the right to the blank separating the two numbers, and replace the blank with a 1 . If the first of the two numbers being added is 0 , then there are not two 1s before the separating blank. Does the algorithm still work in this case?

Chris Trentman
Chris Trentman
Numerade Educator
01:42

Problem 27

Draw a state diagram for a Turing machine that takes any string of 1 s and changes every third 1 to a 0. Thus, for example,
...b111111b...
becomes
b110110b...

Adriano Chikande
Adriano Chikande
Numerade Educator
07:50

Problem 28

Draw a state diagram for a Turing machine that increments a binary number. Thus, if the binary representation of 4 is initially on the tape, b100... then the output is the binary representation of 5 , $.6101 .$.
or if the initial tape contains the binary representation of 7 ,
b1116...
then the output is the binary representation of 8 , $.61000 b \ldots$

Chris Trentman
Chris Trentman
Numerade Educator
02:21

Problem 29

Analyze the time and space efficiency of the following Turing machine operating on a unary string of length $n$.
$$
\begin{aligned}
& (1,1,1,1, R) \\
& (1, b, b, 2, L) \\
& (2,1,0,2, L) \\
& (2, b, b, 3, R) \\
& (3,0,1,3, R)
\end{aligned}
$$

James Kiss
James Kiss
Numerade Educator

Problem 30

Suppose we already have Turing machine instructions to copy a unary string; we al so know how to add two unary numbers. Describe (in words only) the design of a Turing machine to multiply two unary numbers.

Check back soon!
02:41

Problem 31

Two other Turing machine unary addition algorithms follow.
1. Fill in the separating blank with a 1, go to the far right end, and erase two $1 \mathrm{~s}$.
2. Erase a 1 on the leftend, fill in the separating blank with a 1 , and erase a 1 on the right end.
a. Do both of these algorithms work correctly?
b. Write the Turing machine for each of these algorithms.
c. Informally, which of the three addition algorithms (the one given in the chapter and these two) seems most time efficient?
d. Suppose that the numbers to be added are $n$ and $m$. The original tape contains the unary representation of $n$, followed by a blank, followed by the unary representation of $m$.

Chris Trentman
Chris Trentman
Numerade Educator
04:10

Problem 32

A palindrome is a string of characters that reads the same forward and backward, such as radar or IUPUI. Write a Turing machine to decide whether any binary string is a palindrome by halting with a blank tape if the string is a palindrome and halting with a nonblank tape if the string is not a palindrome.
Note: The world's longest single-word palindrome is the Finnish word for "lye dealer":
Saippuakivikauppias
Other palindromes include:
Slap a ham on Omaha pals
Do geese see god
A man a plan a canal Panama

Bryan Lynn
Bryan Lynn
Numerade Educator
05:34

Problem 33

The following BNF grammar defines a set of binary strings.
$\langle$ string $\rangle::=\langle$ one $\rangle \mid\langle$ <one $\rangle\langle$ string $\rangle$
<ones $::=1$
a. Describe the language defined by this grammar.
b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.

Chris Trentman
Chris Trentman
Numerade Educator
07:01

Problem 34

The following BNF grammar defines a set of binary strings.
$\langle$ string $\rangle:=\langle$ zero $\rangle\langle$ zero $\rangle\langle$ string $\rangle \mid<$ one $\rangle$
$\langle$ zero $>::=0$
<ones $::=1$
a. Describe the language defined by this grammar.
b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.

Chris Trentman
Chris Trentman
Numerade Educator
07:01

Problem 35

The following BNF grammar defines a set of binary strings.
$$
\begin{aligned}
& \langle\text { string }\rangle:=\langle\text { zero }\rangle\langle A\rangle\langle\text { zero }\rangle \\
& \langle A\rangle:=\langle\text { zero }\rangle\langle B\rangle\langle\text { zero }\rangle \\
& \langle B\rangle:=\langle 0 n e\rangle\langle B\rangle \mid\langle\text { one }\rangle \\
& \langle\text { zero }\rangle::=0 \\
& \langle 0 \text { en }\rangle:=1
\end{aligned}
$$
a. Describe the language defined by this grammar.
b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.

Chris Trentman
Chris Trentman
Numerade Educator
07:01

Problem 36

The following BNF grammar defines a set of binary strings.
$$
\begin{aligned}
& \langle\text { string }\rangle::=\langle\text { zero }\rangle\langle\text { one }\rangle \mid\langle\text { zero }\rangle\langle\text { string }\rangle\langle\text { <one }\rangle \\
& \langle\text { zero }\rangle:=0 \\
& \langle\text { one }\rangle:=1
\end{aligned}
$$
a. Describe the language defined by this grammar.
b. Write a Turing machine to decide whether any binary string is a string in this language by halting with a blank tape if the string is in the language and halting with a nonblank tape if the string is not in the language.

Chris Trentman
Chris Trentman
Numerade Educator

Problem 37

Your boss gives you a computer program and a set of input data and asks you to determine whether the program will get into an infinite loop running on these data. You report that you cannot do this job, citing the Church-Turing thesis. Should your boss

Check back soon!

Problem 38

What is the significance of the unsolvability of the halting problem?

Check back soon!

Problem 39

The uniform halting problem is to decide, given any collection of Turing machine instructions, whether that Turing machine will halt for every input tape. This is an unsolvable problem. Which of the three oractical consequences of unsolvability problems described in Section 12.7 follows from the uniform nalting problem?

Check back soon!

Problem 40

The 10-step halting problem is to decide, given any collection of Turing machine instructions, together with any initial tape contents, whether that Turing machine will halt within 10 steps when started on that tape. Explain why the 10-step halting problem is computable.

Check back soon!