Exercises
The following exercises provide you with the opportunity to practice with graphs. The solutions to these exercises are found in the section, Chapter 18.
-
The first graph powers an e-commerce store’s recommendation engine. Each vertex represents a product available on the store’s website. The edges connect each product to other “similar” products the site will recommend to the user when browsing a particular item.
If the user is browsing “nails,” what other products will be recommended to the user?
-
If we perform depth-first search on the second graph starting with the “A” vertex, what is the order in which we’ll traverse all the vertices? Assume that when given the choice to visit multiple adjacent vertices, we’ll first visit the node ...
Get A Common-Sense Guide to Data Structures and Algorithms, Second Edition, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.