{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2c03-review - 00075

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

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

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 pass1 a b b 3 pass2 a B 2 pass3 A b b 3 pass4 a b b 3 pass5 a b 2 pass6 a b b 3 pass7 a b b a b a b a a a b a b 13 Total 29 3.[16] Abstract Data Type DIGRAPH involves the following 3 operations on directed graphs : FIRST(v) - returns the index for the first vertex adjacent to v. The index for the null vertex is returned if there is no vertex adjacent to v. NEXT(v,i) - returns the index after index i for the vertices adjacent to v. The null vertex is returned if i is the last index for vertices adjacent to v. VERTEX(v,i) - returns the vertex with index i among the vertices adjacent to v.
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

{[ snackBarMessage ]}

Ask a homework question - tutors are online