Exercise · Volume 1 · 2.2.4-6
Exercise 2.2.4-6
not stated yet in Lean solution written
| Rating | 18 |
|---|---|
| Kind | K8, compute by machine: find a number or an object by a large computation from the written solution |
| Section | Section 2.2.4 of Volume 1 |
The task
Draw the list representation of the polynomials (a) and (b) .
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 , , of , , in the first three bytes of the other word, followed by the link.
Hint 2
The sentinel at the end has and coefficient , and it links to the first term.
Solution
Show the solution
The terms are in decreasing order of , and the pointer is at the sentinel.
(a) The term has , , and coefficient . The constant has and coefficient . In the form coefficient, :
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 and in this order, and the next link returns to the sentinel, whose 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 .
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.