Homework 17: Simple Graph Search
Submit this homework using Gradescope. You can type up your answers, or write legibly and scan them. Do not attempt to submit a paper copy in class, as it will not be accepted.
(1 point) Suppose you treat the integers as a graph. In other words, there are an infinite number of vertices; 0 is adjacent to -1 and 1; 1 is adjacent to 0 and 2; and so on. This representation is similar to the “number line” that is sometimes used to teach basic arithmetic.
If you were to perform a breadth-first search, starting at 0 and with a goal of 3, in what order would the integers be visited? Assume that the neighbors of each integer are returned in their natural order (for example, the neighbors of 0 are -1 and 1, in that order).