cs - bft(n) visit n mark as visited enqueue n while the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 ostringstream oss<<d ----- cout.setf(. ..) cout.setf(. ..) cout.precision(3) Graph representations dependencies 0-> 1 3 1-> 1 24 2-> 3->4 4->0 dft(n) //recursive depth first algorithm visit n mark n as visited // if theres a cycle, or you redo work for each unvisited successor of n dft(that successor) Breath First Traversal distance 1, distance 2, distance 3 best modelled with a queue (non recursive)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: bft(n) visit n mark as visited enqueue n while the queue isnt empty dequeue a node, mark it n for each unvisited successor of n visit it mark as visited enqueue n directed acyclic graphs ex: production of item depends on things getting done first ex: coursework topological sort saturday final 3/15 3-6 3...
View Full Document

Ask a homework question - tutors are online