c340s01t3 - CSc 340 Test 3 Wednesday 18 April...

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

View Full Document Right Arrow Icon
CSc 340 Test 3 Wednesday 18 April 2001 ---------------------------------------------------------------- SUGGESTED ANSWERS ---------------------------------------------------------------- 1. Show the nine comparisons which would occur when the tournament algorithm is applied to find the 2nd largest entry in the array x[1],. ..,x[8] = {8, 4, 9, 7, 3, 2, 6, 1}. In practice, of course, the algorithm does not know the entries and only compares them. 8 -- 8 -- 4 --/ \ 9 -- 9 -- 9 --- 9 Now we search for the 8 -- 8 -- 8 7 --/ / maximum among the losers 7 --/ / 3 -- 3 -- / to 9 6 ------/ 2 --/ \ / 6 -- 6 -- 6 -- 1 --/ Every pair of parallel lines stand for 1 comparison. There are 9 such comparisons. 2. Assume G=(V,E,W) is a weighted, directed graph such that the subgraph of all nodes reachable from node 1 is a tree rooted at node 1. Also assume that int A[][] is the adjacency matrix for G, where A[i][j]=0 indicates the lack of an arc from i to j, and A[i][j]>0 is the weight when there is an arc from i to j.
Background image of page 1

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

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

Page1 / 2

c340s01t3 - CSc 340 Test 3 Wednesday 18 April...

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

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