This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: o USE A STACK/RECURSION o Basic operations? • Visiting O(1) Do this n times • Checking if a neighbor is visited O(1) Directed: do this e times Undirected: do this 2e times • Run time: O(n+e) 1. Breadth-first search (BFS) o Enqueue root o Visit the children of the root, add children to queue o Dequeue-> this is new root o Repeat until queue is empty && all nodes visited o Basic operations • Visiting n • Check neighbor Directed: e Undirected: 2e • Enqueue n • Dequeue n o Runtime: O(n+e)...
View Full Document
This note was uploaded on 02/29/2012 for the course 198 112 taught by Professor Venugopal during the Spring '09 term at Rutgers.
- Spring '09