Graphs 3.2 - a Linear Order Alg: DFS Found Not Handled...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a Linear Order Alg: DFS Found Not Handled Stack h i j k b c d e g f l Linear Order: CSE 2011 Prof. J. Elder - 111 - a,h,b,c,i,j,k,d,e,g,l,f Done! Last Updated: 4/1/10 10:16 AM DFS Algorithm for Topologial Sort Makes sense. But how do we prove that it works? CSE 2011 Prof. J. Elder - 112 - Last Updated: 4/1/10 10:16 AM Linear Order Proof: Consider each edge •Case 1: u goes on stack first before v. •Because of edge, v goes on before u comes off •v comes off before u comes off •v goes after u in order. Found Not Handled Stack … v … u u CSE 2011 Prof. J. Elder v - 113 - u…v… Last Updated: 4/1/10 10:16 AM Linear Order Proof: Consider each edge •Case 1: u goes on stack first before v. •Case 2: v goes on stack first before u. v comes off before u goes on. •v goes after u in order. Found Not Handled Stack … u v u CSE 2011 Prof. J. Elder v - 114 - u…v… Last Updated: 4/1/10 10:16 AM Proof: Consider each edge •Case 1: u goes on stack first before v. •Case 2: v goes on stack first before u. v comes off before u goes on. Case 3: v goes on stack first before u. u goes on before v comes off. •Panic: u goes after v in order. •Cycle means linear order is impossible Found Not Handled Stack u …… Linear Order v The nodes in the stack form a path starting at s. u v CSE 2011 Prof. J. Elder - 115 - v…u… Last Updated: 4/1/10 10:16 AM ...
View Full Document

Page1 / 5

Graphs 3.2 - a Linear Order Alg: DFS Found Not Handled...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online