Back to problems

Implement a Web Crawler with BFS and DFS

Algorithm · Google · Medium

Implement two deterministic crawlers for an in-memory directed graph of pages. The graph is given as a dictionary whose keys are URL strings and whose values are lists of URL strings that the key page links to. If a URL does not appear as a key, treat it as a page with no outgoing links. Write crawl_dfs(graph, start_url, max_pages) and crawl_bfs(graph, start_url, max_pages). Each function returns the visited URLs in the exact order they are visited. When max_pages > 0,…

Checking your access…