This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 5. a. In breadth-first search, we search the root first, then all nodes of depth 1, then all nodes of depth 2, and so on. Nodes at the same depth are searched in left-to-right order. For following tree: We search in the order of a, b, c, d, e, f, g, h. b. procedure breadth-first-search(x:elementtype, T:tree):boolean var level: QUEUE of nodes; v: node; begin v:= ROOT(T); MAKENULL_QUEUE(level); ENQUEUE(v, level); while not empty(level) do begin v:=FRONT(level); DEQUEUE(level);...
View Full Document
This note was uploaded on 12/10/2009 for the course CAS 2c03 taught by Professor Janicki during the Spring '03 term at McMaster University.
- Spring '03