What is the primary motivation for using a sparse representation (a list of non-zero terms) for polynomials instead of a dense one (a list of all coefficients)?

Correct answer: It is more efficient for polynomials that have many zero terms.

Explanation

Choosing the right data representation is crucial for performance. For polynomials that are 'sparse' (having few non-zero terms over a large range of powers), a representation that only stores the non-zero terms is far more space- and time-efficient than one that stores all coefficients, including the zeros.

Other questions

Question 1

What is the primary purpose of data abstraction in program design, as introduced in the chapter?

Question 2

In the rational-number arithmetic system example, what set of functions forms the abstraction barrier between the operations like `add_rat` and the underlying representation of rational numbers as pairs?

Question 3

What is the key characteristic of an operation that possesses the 'closure property'?

Question 4

Given the list `const squares = list(1, 4, 9, 16, 25);`, what is the result of evaluating `list_ref(squares, 3)`?

Question 5

What is the fundamental difference between the `append` function and the `append_mutator` function described in Exercise 3.12?

Question 6

What does the higher-order function `map` do when applied to a function and a list?

Question 7

In the functional representation of pairs where `function pair(x, y) { return m => m(x, y); }`, what is the correct definition for `tail(z)`?

Question 8

According to the symbolic differentiation example, how is the algebraic expression `ax + b` represented using prefix notation in list structure?

Question 9

When representing a set as an ordered list of numbers, what is the order of growth in the number of steps for the `intersection_set` operation for two sets of size n?

Question 10

In a Huffman encoding tree, where is the information about the relative frequency of symbols (the weights) used?

Question 11

What is the purpose of using type tags in a data system with multiple representations, such as the complex number example?

Question 12

What is a major weakness of implementing generic operations using explicit dispatch-on-type (as in Section 2.4.2) that data-directed programming aims to solve?

Question 13

What is the process of viewing an object of one type as an equivalent object of another type called in the context of generic arithmetic?

Question 14

Consider the representation of a set as a balanced binary tree. What is the order of growth for checking if an element is in a set of size n?

Question 15

In the `count_leaves` function for a tree, what is the base case for a leaf node (an object that is not null and not a pair)?

Question 16

Given the list structure created by `const x = list(list(1, 2), list(3, 4));`, what is the result of `length(x)`?

Question 17

What is meant by a 'headed list' in the context of the table implementation in Section 3.3.3?

Question 18

Why is the first version of the rational-number implementation in Section 2.1.1, which does not reduce fractions, considered incomplete or imperfect?

Question 19

In the signal-flow model for sequence processing, what is the role of the `filter` operation?

Question 20

What is the result of evaluating `equal(list("a", "b"), list("a", "b"))` according to the definition in Exercise 2.54?

Question 21

When Alyssa P. Hacker represents complex numbers in polar form, which function is straightforward to implement?

Question 22

In the message-passing implementation of `make_from_real_imag(x, y)`, what does the function actually return?

Question 23

According to Exercise 2.1, if `make_rat` is modified to normalize the sign of a rational number, what should `make_rat(-2, -3)` produce internally before creating the pair?

Question 24

What does the function `flatmap` do, as defined in the section on nested mappings?

Question 25

In the eight-queens puzzle implementation, what does the function `queen_cols(k)` aim to return?

Question 26

What is the result of the expression `const z2 = pair(list("a", "b"), list("a", "b"));` followed by `head(z2) === tail(z2)`?

Question 27

In the picture language from Section 2.2.4, what is a `painter` represented as?

Question 28

What is stratified design, as described in the context of the picture language?

Question 29

What is the value of the expression `member("red", list("red", "shoes", "blue", "socks"))`?

Question 30

In the context of the generic arithmetic system in Section 2.5, what is a 'tower of types'?

Question 31

When defining the `mul_poly` function for multiplying two polynomials, how is the coefficient of a new term calculated?

Question 33

In the `div_rat` function for rational numbers, the returned rational number is `make_rat(numer(x) * denom(y), denom(x) * numer(y))`. What mathematical operation does this correspond to?

Question 34

What is the purpose of the `is_pair` predicate in the `count_leaves` function?

Question 35

According to the definition of a queue in Section 3.3.2, which operation removes an item from the sequence?

Question 36

Why is the simple list representation for a queue inefficient for the `insert_queue` operation?

Question 37

In the `permutations` function from Section 2.2.3, what is the base case for the recursion?

Question 38

If `deriv` is called with the expression `list("*", "x", "y")` and the variable `"x"`, what is the unsimplified result?

Question 39

What does the `put(op, type, item)` function do in the data-directed programming framework?

Question 40

In the extended exercise on interval arithmetic, why does Lem E. Tweakit's program give different answers for the two algebraically equivalent formulas for parallel resistance?

Question 41

Consider the representation of points and line segments in Exercise 2.2. A point is a pair of numbers (x, y) and a segment is a pair of points. How would you select the y-coordinate of the end point of a segment `s`?

Question 42

What is the key idea behind the `accumulate` function introduced in Exercise 1.32 and used in Section 2.2.3?

Question 43

In the representation of a queue as a pair of pointers (front_ptr, rear_ptr), what is the state of an empty queue created by `make_queue()`?

Question 44

If you evaluate `horner_eval(2, list(1, 3, 0, 5, 0, 1))`, which polynomial is being evaluated?

Question 45

The function `square_of_four` in Section 2.2.4 abstracts a pattern of painter combination. What does it take as arguments?

Question 46

In the `accumulate_n` function from Exercise 2.36, what does the first `??` in `pair(accumulate(op, init, ??), ...)` represent?

Question 47

What is the result of `dot_product(list(1, 2, 3), list(4, 5, 6))` as defined in Exercise 2.37?

Question 48

According to footnote 2 on page 74, what is a potential disadvantage of defining `make_rat` as `const make_rat = pair;`?

Question 49

What does Euclid's Algorithm, as presented for polynomial GCD in Exercise 2.94, rely on?

Question 50

In the two-dimensional table implementation, how is a subtable identified when performing a lookup?