# FinalAns - The answers below are numbered in the order of...

This preview shows pages 1–4. Sign up to view the full content.

The answers below are numbered in the order of the questions for version A. Here is the correspondence for the other versions. Version A, number here 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Version B, number here 5 17 3 15 23 21 9 28 16 18 6 2 24 27 8 Version C, number here 20 12 1 11 15 16 19 25 8 24 23 29 18 5 27 Version A, number here 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Version B, number here 10 13 14 29 7 26 22 30 11 19 20 25 4 12 1 Version C, number here 22 26 3 10 17 21 9 28 13 4 7 14 30 6 2 How to interpret scramble: Question 1 here is Question 1 on version A, Question 5 on version B, and Question 20 on version C. For each question choose the best possible alternative and mark your choice on the bubble answer sheet. Only one choice per question is allowed. The lowest (best) complexity in the worst-case means the choice with the lowest complexity for all the choices in the worst-case. 1. Given the graph

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

View Full Document
Which choice represents a valid possibility for the order to visit nodes in a breadth-first search starting at node 1? When you have a choice of where to go, always choose the smallest numbered node first . A. 1 2 6 7 4 3 5 8 B. 1 2 4 5 6 3 7 C. 1 2 3 4 5 6 7 D. 1 2 6 7 3 4 5 E. 1 2 6 7 4 3 5 In a breadth-first search you visit all nodes the same number of arcs away before going to the next level. You visit nearer nodes first. Thus, the correct answer is B. You cannot get to 8. You also must go to 4 to get to 3 due to the direction of the arc from 3 to 1. 2. Which of the following statements is true ? A . The average-case and worst-case complexity for binary search on an array are the same. B. Binary search on an array and binary search trees have the same worst-case complexity in all cases where they contain the same items. C. For an array of length N it always takes N operations to find an item using sequential search. D. Binary search can be applied to any array. E. Binary search on an array needs the use of a temporary array. Binary search takes O(log(N)) for both the average and worst-case so A is the correct answer. A binary search tree is O(N) in the worst-case so B is wrong. For sequential search you can stop when you find the item so C is wrong. Binary search only works on a sorted array so D is wrong. Binary search needs no extra memory so E is wrong. 3. You are given the following graph
If you performed a valid topological numbering of the graph starting from node A, which ordering of nodes below would represent a valid sequence of nodes? The sequence is determined such that a lower numbered node (must be done earlier) in the topological numbering comes first (to the left side) in the sequence. For example, if A is first (farthest to the left) then it has the lowest number value. A. A B C D E F

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/17/2011 for the course CS 367 taught by Professor Marvinsolomon during the Spring '08 term at University of Wisconsin.

### Page1 / 17

FinalAns - The answers below are numbered in the order of...

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

View Full Document
Ask a homework question - tutors are online