2c03-review - 00075

2c03-review - 00075 - VERTEX(v,i) - returns the vertex with...

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

View Full Document Right Arrow Icon
2 Using KMP a b a A b a b a a b a b b a b a b a a a b a b a a b a b b # of comparisons p a s s 1 a b b 3 p a s s 2 a B 2 p a s s 3 A b b 3 p a
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: VERTEX(v,i) - returns the vertex with index i among the vertices adjacent to v. Implement the operations FIRST, NEXT, and VERTEX for digraphs represented by a. Adjacency matrices b. Linked adjacency lists a[8] Adjacency matrices function FIRST(v:integer):integer; var i:integer; begin for i:=1 to n do if A[v,i]=1 then return(i); return(0) { if we reach here, v has no adjacent vertex} end function NEXT(v:integer; i:integer):integer; var j:integer; begin for j:= i+1 to n do if A[v,i]=1 then return(j); return(0) end function VERTEX(v,i:integer): integer begin return(i) end...
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.

Ask a homework question - tutors are online