Chapter 18
These are the solutions to the exercises found in the section Exercises.
-
If a user is browsing “nails”, the website will recommend “nail polish”, “needles”, “pins”, and “hammer”.
-
The order of depth-first search would be A-B-E-J-F-O-C-G-K-D-H-L-M-I-N-P, as seen in the following image:
-
The order of breadth-first search would be A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P, as seen in the following image:
-
Following is an implementation of breadth-first search:
import Queue from './queue_implementation.js'; function bfs(startingVertex, searchValue) ...
Get A Common-Sense Guide to Data Structures and Algorithms in JavaScript, Volume 1 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.