taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 2.2.4-6

Exercise 2.2.4-6

not stated yet in Lean solution written

Rating18
KindK8, compute by machine: find a number or an object by a large computation from the written solution
SectionSection 2.2.4 of Volume 1

The task

Draw the list representation of the polynomials (a) xz−3xz - 3 and (b) 00.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Each node has the coefficient in one word, and the exponents AA, BB, CC of xx, yy, zz in the first three bytes of the other word, followed by the link.

Hint 2

The sentinel at the end has ABC=−1\mathrm{ABC} = -1 and coefficient 00, and it links to the first term.

Solution

Show the solution

The terms are in decreasing order of ABC\mathrm{ABC}, and the pointer is at the sentinel.

(a) The term xzxz has A=1A = 1, B=0B = 0, C=1C = 1 and coefficient 11. The constant −3-3 has ABC=000\mathrm{ABC} = 000 and coefficient −3-3. In the form coefficient, ABC\mathrm{ABC}:

P -> [ 0 | -001 ] -> [ 1 | +101 ] -> [ -3 | +000 ] -> back to the sentinel

The sentinel is at the left, and the last link returns to it.

(b) The zero polynomial has no terms, so the list is the sentinel alone, and its link points to itself:

P -> [ 0 | -001 ] -> back to itself

Check

Walking from the sentinel in (a) gives the terms +101+101 and +000+000 in this order, and the next link returns to the sentinel, whose ABC\mathrm{ABC} is negative. In (b) the first link already returns to the sentinel, so the walk visits no term.

Remarks

The sentinel stops every loop of the algorithms, since no real term has a negative ABC\mathrm{ABC}.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.