From: Thomas Walker Lynch Date: Sun, 19 Jul 2026 14:56:25 +0000 (+0000) Subject: . X-Git-Url: https://git.reasoningtechnology.com/%27%20%20%20window.RT.dirpr_library%20%20%20%27/Hindu-Arabic%20number%20fig%203.png?a=commitdiff_plain;h=4628c7ebbe1f208948d9f1de20a0c005e8238353;p=TM-2026 . --- diff --git a/document/book/HU_reverse_machine.png b/document/book/HU_reverse_machine.png deleted file mode 100644 index 9771cfb..0000000 Binary files a/document/book/HU_reverse_machine.png and /dev/null differ diff --git a/document/book/HU_reverse_machine.yaml b/document/book/HU_reverse_machine.yaml deleted file mode 100644 index ae67be8..0000000 --- a/document/book/HU_reverse_machine.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# enter this at https://TuringMachine.io/ -# Reverses a binary string -input: '11001' -blank: ' ' -start state: q0 -table: - # scan to the rightmost digit and place the EOM terminator 'E' - q0: - [0, 1]: R - ' ' : {write: 'E', L: q1} - - # process the rightmost unmarked digit, writing the uniform marker '*' - q1: - 0 : {write: '*', R: q2} - 1 : {write: '*', R: q3} - ' ': {R: q6} # all digits processed, begin cleanup - - # carry '0' to the right end - q2: - ['*', 'E', 0, 1]: R - ' ' : {write: 0, L: q4} - - # carry '1' to the right end - q3: - ['*', 'E', 0, 1]: R - ' ' : {write: 1, L: q4} - - # return all the way to the left blank space - q4: - ['*', 'E', 0, 1]: L - ' ' : {R: q5} - - # step right to find the next unmarked digit - q5: - [0, 1] : R - ['*', 'E']: {L: q1} - - # erase the markers and EOM terminator, leaving only the reversed string - q6: - ['*', 'E'] : {write: ' ', R: q6} - [0, 1, ' ']: {L: done} - - done: diff --git a/document/book/HU_style_TM_reverse.png b/document/book/HU_style_TM_reverse.png new file mode 100644 index 0000000..1aae475 Binary files /dev/null and b/document/book/HU_style_TM_reverse.png differ diff --git a/document/book/TM-2026.html b/document/book/TM-2026.html index af67c23..0229d69 100644 --- a/document/book/TM-2026.html +++ b/document/book/TM-2026.html @@ -342,7 +342,7 @@ The computation theoretic Turing Machine -

The Hopcroft and Ullman Turing Machine

+

The Hopcroft and Ullman Turing Machine

This definition comes from Hopcroft and Ullman's book with minor terminology changes to make it flow into the text here John E. Hopcroft and Jeffrey D. Ullman, Introduction to Automata Theory, Languages, and Computation (Reading: Addison Wesley, 1979)..

@@ -386,63 +386,158 @@

So first the tape is X_1 X_2 \cdots X_{i-1} X_i X_{i+1} \cdots X_n, with the head over X_i, and in state q. Then after a step of the machine, the tape is X_1 X_2 \cdots X_{i-1} Y X_{i+1} \cdots X_n, with the head over X_{i-1}, and in state p. Thus X_i was overwritten with Y, and the head stepped left.

-

Here is the programmed controller for a Turing Machine that reverses a binary string.

+

Here is the programmed controller for a Turing Machine that reverses a binary string. Although by definition each state transition matches exactly one value under the head, as a practical matter, disjunctive selection is allowed via a comma list. A conjunctive phrasing for a state transition proposition would require stringing intermediate states in series.

- HU reverse machine + HU reverse machine

Provided the site is still alive, the following YAML can be entered at TuringMachine.io to watch the machine run.

# YAML # Reverses a binary string using a single marker and an EOM terminator. - input: '11001' + input: ' 110' blank: ' ' - start state: q0 + start state: q_init table: - # scan to the rightmost digit and place the EOM terminator 'E' - q0: + # Machine starts on the leftmost cell (a blank marker). + # Then step right to the first input symbol. + q_init: + ' ': {R: q1} + + # Check for an empty string; exit if true. Otherwise, scan right. + q1: + ' ' : {L: done} + [0, 1]: {R: q_scan} + + # Scan to the rightmost digit and place the EOM terminator 'E' + q_scan: [0, 1]: R - ' ' : {write: 'E', L: q1} + ' ' : {write: 'E', L: q2} # process the rightmost unmarked digit, writing the uniform marker '*' - q1: - 0 : {write: '*', R: q2} - 1 : {write: '*', R: q3} - ' ': {R: q6} # all digits processed, begin cleanup + q2: + 0 : {write: '*', R: s0} + 1 : {write: '*', R: s1} + ' ': {R: q5} # all digits processed, begin cleanup # carry '0' to the right end - q2: + s0: ['*', 'E', 0, 1]: R - ' ' : {write: 0, L: q4} + ' ' : {write: 0, L: q3} # carry '1' to the right end - q3: + s1: ['*', 'E', 0, 1]: R - ' ' : {write: 1, L: q4} + ' ' : {write: 1, L: q3} # return all the way to the left blank space - q4: + q3: ['*', 'E', 0, 1]: L - ' ' : {R: q5} + ' ' : {R: q4} # step right to find the next unmarked digit - q5: + q4: [0, 1] : R - ['*', 'E']: {L: q1} + ['*', 'E']: {L: q2} # erase the markers and EOM terminator, leaving only the reversed string - q6: - ['*', 'E'] : {write: ' ', R: q6} + q5: + ['*', 'E'] : {write: ' ', R: q5} [0, 1, ' ']: {L: done} done: -

This machine starts with the head on the leftmost symbol of the input string, requiring an empty symbol on both sides to operate. The machine begins by sweeping right to place an end of message marker, E, immediately after the string. It then enters a repetitive process: it walks left to locate the next unprocessed input symbol, overwrites it with an asterisk to mark it as read, and then carries that remembered value rightward to deposit it at the new end of the sequence. By executing this back-and-forth shuttle, the machine systematically builds the reversed string to the right of the E, finishing by sweeping through to erase its temporary markers.

+

By default a newly initialized machine always starts with the head on the leftmost tape cell. The input is specified to be placed one square past the initial blank on the tape. This allows the leftmost blank to be used as a reliable start of input marker later when it is scanning left. The machine begins by reading this initial blank and stepping right. If it immediately encounters another blank, the string is empty and the machine is done. Otherwise, it sweeps right to place an end of message marker, E, immediately after the string. It then enters a repetitive process: it walks left to locate the next unprocessed input symbol, overwrites it with an asterisk to mark it as read, and then carries that remembered value rightward to deposit it at the new end of the sequence. By executing this back and forth shuttle, the machine systematically builds the reversed string to the right of the E, finishing by sweeping through to erase its temporary markers.

+ +

The following trace demonstrates the reversal of the string "110" using the same head embedded in the tape diagram as was used above, with a small variation. Here the head position is indicated using a bullet character, while the current state is listed in the left column. The empty symbol prints as a space. If you align the first line at the top of your window and scroll down, the execution plays out like an animation.

-

Reversing a string does not in general require knowing the constituent symbols; however, a Turing Machine is incapable of ignoring their actual values. The 1 and 0 here are explicitly stated in the state transitions, and specific states are reserved to keep track of which symbol is being transferred. Had the input alphabet been large, this controller would have required proportionally more states.

+ + q_init • 1 1 0 + q1 •1 1 0 + q_scan 1•1 0 + q_scan 1 1•0 + q_scan 1 1 0• + q2 1 1•0 E + s0 1 1 *•E + s0 1 1 * E• + q3 1 1 *•E 0 + q3 1 1•* E 0 + q3 1•1 * E 0 + q3 •1 1 * E 0 + q3 • 1 1 * E 0 + q4 •1 1 * E 0 + q4 1•1 * E 0 + q4 1 1•* E 0 + q2 1•1 * E 0 + s1 1 *•* E 0 + s1 1 * *•E 0 + s1 1 * * E•0 + s1 1 * * E 0• + q3 1 * * E•0 1 + q3 1 * *•E 0 1 + q3 1 *•* E 0 1 + q3 1•* * E 0 1 + q3 •1 * * E 0 1 + q3 • 1 * * E 0 1 + q4 •1 * * E 0 1 + q4 1•* * E 0 1 + q2 •1 * * E 0 1 + s1 *•* * E 0 1 + s1 * *•* E 0 1 + s1 * * *•E 0 1 + s1 * * * E•0 1 + s1 * * * E 0•1 + s1 * * * E 0 1• + q3 * * * E 0•1 1 + q3 * * * E•0 1 1 + q3 * * *•E 0 1 1 + q3 * *•* E 0 1 1 + q3 *•* * E 0 1 1 + q3 •* * * E 0 1 1 + q3 • * * * E 0 1 1 + q4 •* * * E 0 1 1 + q2 • * * * E 0 1 1 + q5 •* * * E 0 1 1 + q5 •* * E 0 1 1 + q5 •* E 0 1 1 + q5 •E 0 1 1 + q5 •0 1 1 + done • 0 1 1 + + +

Reversing a string does not intrinsically require making decisions based on the values in the string that is being reversed; however, a Turing Machine must use the value under the head for the next state transitions. Also, the only memory a controller has through adding control path branches, so to "carry the symbol right" requires a branch in the state controller to remember what the symbol is. Consequently had the input alphabet been larger, this controller would have required proportionally more states, as noted on the diagram.

+ +

The total number of states in the machine for reversing an input string, when data symbols come from an alphabet of cardinality n:

+ +

The total number of states in the machine for reversing an input string, when data symbols come from an alphabet of cardinality n:

+ +
+ + \text{states} = n + 8 + +
+ +

The number of arcs in the machine, when data symbols come from an alphabet of cardinality n:

+ +
+ + \text{arcs} = n^2 + 9n + 12 + +
+ +

The total number of steps for reversing an n character string:

+ +
+ + \text{steps} = + \begin{cases} + 2 & \text{if } n = 0 \\ + 3n^2 + 6n + 5 & \text{if } n \ge 1 + \end{cases} + +
-

Although by definition each state transition matches one value under the head, as a practical matter, disjunctive selection is allowed via a comma list. A conjunctive phrasing for the state transition proposition would require stringing intermediate states in series.

Blank, empty, SP

@@ -477,14 +572,10 @@ def write(c, x): - if x == 'empty': - if(is_empty(c): return - else: - c.pop() - return - else: - c.pop() - c.put(x) + if not is_empty(c): + c.pop() # Clear the cell if it holds something + if x != 'empty': + c.put(x) # Place the new symbol unless we are just erasing

Now imagine machine B, where the concept of an empty cell is jettisoned, and what remains is the mere memory of emptiness, a symbol called empty. Then using the language of mathematics, the mathematician defines an initial empty tape as:

@@ -564,7 +655,7 @@

There is a mechanical procedure for converting a Moore Machine into a Mealy Machine, and the reverse. Two such converted machines are equally expressive. Making the read operation an explicit action, instead of having it implied by a state transition, increases the number of states in a controller, and consequently the number of steps that must be taken. However, the new machine can do in two steps anything the former machine could do in one; consequently, this change affects the multiplier constant on the linear term of the step count formula but does not change the computation complexity class determined from such a step count. The layers of next-state functions can be collapsed into one layer, where the missing arguments are filled in with all possible unused values. This potentially increases the number of state transition arcs that must be specified, but the state transition logic and the number of states remain unchanged. Partitioning the machine definition by separation of concerns does not change the total specification. Hence, these modifications are computationally inconsequential.

-

The TTCA Turing Machine fixed part

+

The TTCA Turing Machine fixed part

@@ -724,7 +815,7 @@
  • The current state q is set to QF{·}\mathtt{initial}.
  • The data register d is initialized to hold the ΣF{·}\mathtt{unspecified} symbol.
  • -
  • The gate register g is initialized to the value under the head.
  • +
  • The gate register g is initialized ΣF{·}\mathtt{unspecified} symbol.

Phase 1: The action

@@ -756,9 +847,9 @@

Here is the programmed controller for the TTCA string reverse. Because actions (λ) are bound to states rather than transitions, reading and stepping are distinct states, resulting in a strictly serialized execution.

- + # TTCA String Reverse - # message: (σ ∈ Σ)* EOM + # input: (σ ∈ Σ)* EOM (starting on the leftmost cell) # output: SP* EOM (σ ∈ Σ in reverse)* EOR halt: Q·Done @@ -795,16 +886,22 @@ Q·Fetch_1: λ: read_g δ: - (EOM: Q·Fetch_0) - (SP: Q·Fetch_0) - Q·Fetch_2 + (EOM: Q·Check_Boundary) + (SP: Q·Check_Boundary) + Q·Read_Data - Q·Fetch_2: + Q·Check_Boundary: + λ: status + δ: + (on_leftmost: Q·Done) + Q·Fetch_0 + + Q·Read_Data: λ: read_d δ: - Q·Fetch_3 + Q·Check_Last_Char - Q·Fetch_3: + Q·Check_Last_Char: λ: status δ: (on_leftmost: Q·Place_Last) @@ -888,8 +985,6 @@ Q·Done - - The Turing Machine architecture/organization

@@ -3963,6 +4058,6 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos --> --> diff --git a/document/book/temp.txt b/document/book/temp.txt new file mode 100644 index 0000000..f2ea1cc --- /dev/null +++ b/document/book/temp.txt @@ -0,0 +1,303 @@ + + q_init . 1 1 0 + q0 .1 1 0 + q_scan 1.1 0 + q_scan 1 1.0 + q_scan 1 1 0. + q1 1 1.0 E + q2 1 1 *.E + q2 1 1 * E. + q4 1 1 *.E 0 + q4 1 1.* E 0 + q4 1.1 * E 0 + q4 .1 1 * E 0 + q4 . 1 1 * E 0 + q5 .1 1 * E 0 + q5 1.1 * E 0 + q5 1 1.* E 0 + q1 1.1 * E 0 + q3 1 *.* E 0 + q3 1 * *.E 0 + q3 1 * * E.0 + q3 1 * * E 0. + q4 1 * * E.0 1 + q4 1 * *.E 0 1 + q4 1 *.* E 0 1 + q4 1.* * E 0 1 + q4 .1 * * E 0 1 + q4 . 1 * * E 0 1 + q5 .1 * * E 0 1 + q5 1.* * E 0 1 + q1 .1 * * E 0 1 + q3 *.* * E 0 1 + q3 * *.* E 0 1 + q3 * * *.E 0 1 + q3 * * * E.0 1 + q3 * * * E 0.1 + q3 * * * E 0 1. + q4 * * * E 0.1 1 + q4 * * * E.0 1 1 + q4 * * *.E 0 1 1 + q4 * *.* E 0 1 1 + q4 *.* * E 0 1 1 + q4 .* * * E 0 1 1 + q4 . * * * E 0 1 1 + q5 .* * * E 0 1 1 + q1 . * * * E 0 1 1 + q6 .* * * E 0 1 1 + q6 .* * E 0 1 1 + q6 .* E 0 1 1 + q6 .E 0 1 1 + q6 .0 1 1 + don . 0 1 1 + + + + + q_init · 1 1 0 + q0 ·1 1 0 + q_scan 1·1 0 + q_scan 1 1·0 + q_scan 1 1 0· + q1 1 1·0 E + q2 1 1 *·E + q2 1 1 * E· + q4 1 1 *·E 0 + q4 1 1·* E 0 + q4 1·1 * E 0 + q4 ·1 1 * E 0 + q4 · 1 1 * E 0 + q5 ·1 1 * E 0 + q5 1·1 * E 0 + q5 1 1·* E 0 + q1 1·1 * E 0 + q3 1 *·* E 0 + q3 1 * *·E 0 + q3 1 * * E·0 + q3 1 * * E 0· + q4 1 * * E·0 1 + q4 1 * *·E 0 1 + q4 1 *·* E 0 1 + q4 1·* * E 0 1 + q4 ·1 * * E 0 1 + q4 · 1 * * E 0 1 + q5 ·1 * * E 0 1 + q5 1·* * E 0 1 + q1 ·1 * * E 0 1 + q3 *·* * E 0 1 + q3 * *·* E 0 1 + q3 * * *·E 0 1 + q3 * * * E·0 1 + q3 * * * E 0·1 + q3 * * * E 0 1· + q4 * * * E 0·1 1 + q4 * * * E·0 1 1 + q4 * * *·E 0 1 1 + q4 * *·* E 0 1 1 + q4 *·* * E 0 1 1 + q4 ·* * * E 0 1 1 + q4 · * * * E 0 1 1 + q5 ·* * * E 0 1 1 + q1 · * * * E 0 1 1 + q6 ·* * * E 0 1 1 + q6 ·* * E 0 1 1 + q6 ·* E 0 1 1 + q6 ·E 0 1 1 + q6 ·0 1 1 + don · 0 1 1 + + +---- + + +

The Hopcroft and Ullman Turing Machine

+ +

This definition comes from Hopcroft and Ullman's book with minor terminology changes to make it flow into the text here John E. Hopcroft and Jeffrey D. Ullman, Introduction to Automata Theory, Languages, and Computation (Reading: Addison Wesley, 1979).. +

+ + + M = (Q, Σ, Γ, δ, q_0, □, F) + + +

Where the components have the following meanings:

+ +
    +
  • Q: The finite set of states of the programmed finite state machine controller.
  • +
  • Σ: The finite set of input symbols.
  • +
  • Γ: The complete set of tape symbols; Σ is always a subset of Γ.
  • +
  • □: The empty symbol. This symbol belongs exclusively to Γ, serving as a distinct tape marker rather than an input symbol. The empty symbol initially populates all cells except the finite number containing the input symbols.
  • +
  • δ: The next state function. The arguments of δ(q, X) are a state q and a tape symbol X. The value of δ(q, X), if it is defined, is a triple (p, Y, D), where: +
      +
    1. p is the next state in Q.
    2. +
    3. Y is the symbol in Γ written in the scanned cell, replacing the previous symbol.
    4. +
    5. D is a direction, either L or R, standing for "left" or "right," respectively, directing the head to move either left or right.
    6. +
    +
  • +
  • q_0: The initial state, a member of Q, in which the finite control is found.
  • + +
  • F: The set of final or accepting states, a subset of Q.
  • +
+ +

I have introduced the qualifier programmed in front of the finite state machine controller because each Turing Machine that accomplishes a different task has a different finite state machine controller. The rest of the Turing Machine remains fixed. Hence, when a mathematician defines a custom task controller, he is essentially programming the machine.

+ +

Here the input alphabet is said to be a subset of a larger alphabet. This allows some symbols to be set aside and only used by the machine. In the architecture description given below, those symbols exclusive to the larger set are called control symbols. Hopcroft and Ullman include the empty symbol as a control symbol. However, they have simultaneously listed it as a separate component.

+ +

State transitions are gated by the read value from the tape. Each state transition function includes actions to be taken; hence, their programmable controller is a Mealy style state machine. The step action is mandatory, though it can be in either direction. The write action must be specified, but the write could be the same symbol that is read, making it effectively an optional action.

+ +

Hopcroft and Ullman explain a step of the machine by showing a representation of the tape with the state variable melded in to the left of the currently scanned symbol. Suppose δ(q, X_i) = (p, Y, L); i.e., the next move is leftward. Then, +

+ + + X_1 X_2 \cdots X_{i-1} q X_i X_{i+1} \cdots X_n \underset{M}{\vdash} X_1 X_2 \cdots X_{i-2} p X_{i-1} Y X_{i+1} \cdots X_n + + +

So first the tape is X_1 X_2 \cdots X_{i-1} X_i X_{i+1} \cdots X_n, with the head over X_i, and in state q. Then after a step of the machine, the tape is X_1 X_2 \cdots X_{i-1} Y X_{i+1} \cdots X_n, with the head over X_{i-1}, and in state p. Thus X_i was overwritten with Y, and the head stepped left. +

+ +

Here is the programmed controller for a Turing Machine that reverses a binary string.

+ + HU reverse machine + +

Provided the site is still alive, the following YAML can be entered at TuringMachine.io to watch the machine run.

+ + + # YAML + # Reverses a binary string using a single marker and an EOM terminator. + input: ' 110' + blank: ' ' + start state: q_init + table: + # Machine starts on the leftmost cell (a blank marker). Step right to the first input symbol. + q_init: + ' ': {R: q0} + + # Check for an empty string; exit if true. Otherwise, scan right. + q0: + ' ' : {L: done} + [0, 1]: {R: q_scan} + + # Scan to the rightmost digit and place the EOM terminator 'E' + q_scan: + [0, 1]: R + ' ' : {write: 'E', L: q1} + + # process the rightmost unmarked digit, writing the uniform marker '*' + q1: + 0 : {write: '*', R: q2} + 1 : {write: '*', R: q3} + ' ': {R: q6} # all digits processed, begin cleanup + + # carry '0' to the right end + q2: + ['*', 'E', 0, 1]: R + ' ' : {write: 0, L: q4} + + # carry '1' to the right end + q3: + ['*', 'E', 0, 1]: R + ' ' : {write: 1, L: q4} + + # return all the way to the left blank space + q4: + ['*', 'E', 0, 1]: L + ' ' : {R: q5} + + # step right to find the next unmarked digit + q5: + [0, 1] : R + ['*', 'E']: {L: q1} + + # erase the markers and EOM terminator, leaving only the reversed string + q6: + ['*', 'E'] : {write: ' ', R: q6} + [0, 1, ' ']: {L: done} + + done: + + +

By definition, this machine always starts on the leftmost tape cell. To accommodate this single ended tape model, the input is specified to be placed one square past the initial blank on the tape. This allows the leftmost blank to be used as a reliable start of input marker, effectively establishing a left physical boundary. The machine begins by reading this initial blank and stepping right. If it immediately encounters another blank, the string is empty and the machine exits. Otherwise, it sweeps right to place an end of message marker, E, immediately after the string. It then enters a repetitive process: it walks left to locate the next unprocessed input symbol, overwrites it with an asterisk to mark it as read, and then carries that remembered value rightward to deposit it at the new end of the sequence. By executing this back and forth shuttle, the machine systematically builds the reversed string to the right of the E, finishing by sweeping through to erase its temporary markers.

+ +

Reversing a string does not in general require knowing the constituent symbols; however, a Turing Machine is incapable of ignoring their actual values. The 1 and 0 here are explicitly stated in the state transitions, and specific states are reserved to keep track of which symbol is being transferred. Had the input alphabet been large, this controller would have required proportionally more states.

+ +

Although by definition each state transition matches one value under the head, as a practical matter, disjunctive selection is allowed via a comma list. A conjunctive phrasing for the state transition proposition would require stringing intermediate states in series.

+ +

The following trace demonstrates the reversal of the string "110". Thanks to Unicode, the head position is indicated directly on the tape using a bullet character, while the current state is listed in the left column. The empty symbol prints as a space. If you align the first line at the top of your window and scroll down, the execution plays out like an animation.

+ + + q_init • 1 1 0 + q0 •1 1 0 + q_scan 1•1 0 + q_scan 1 1•0 + q_scan 1 1 0• + q1 1 1•0 E + q2 1 1 *•E + q2 1 1 * E• + q4 1 1 *•E 0 + q4 1 1•* E 0 + q4 1•1 * E 0 + q4 •1 1 * E 0 + q4 • 1 1 * E 0 + q5 •1 1 * E 0 + q5 1•1 * E 0 + q5 1 1•* E 0 + q1 1•1 * E 0 + q3 1 *•* E 0 + q3 1 * *•E 0 + q3 1 * * E•0 + q3 1 * * E 0• + q4 1 * * E•0 1 + q4 1 * *•E 0 1 + q4 1 *•* E 0 1 + q4 1•* * E 0 1 + q4 •1 * * E 0 1 + q4 • 1 * * E 0 1 + q5 •1 * * E 0 1 + q5 1•* * E 0 1 + q1 •1 * * E 0 1 + q3 *•* * E 0 1 + q3 * *•* E 0 1 + q3 * * *•E 0 1 + q3 * * * E•0 1 + q3 * * * E 0•1 + q3 * * * E 0 1• + q4 * * * E 0•1 1 + q4 * * * E•0 1 1 + q4 * * *•E 0 1 1 + q4 * *•* E 0 1 1 + q4 *•* * E 0 1 1 + q4 •* * * E 0 1 1 + q4 • * * * E 0 1 1 + q5 •* * * E 0 1 1 + q1 • * * * E 0 1 1 + q6 •* * * E 0 1 1 + q6 •* * E 0 1 1 + q6 •* E 0 1 1 + q6 •E 0 1 1 + q6 •0 1 1 + done • 0 1 1 + + +

The total number of states for supporting n symbols:

+ +
+ + \text{states} = n + 8 + +
+ +

The total number of steps for reversing an n character string:

+ +
+ + \text{steps} = 3n^2 + 6n + 5 + +
+ +

The number of arcs that make decisions based on the data being reversed:

+ +
+ + \text{steps} = + +
+