q9 sol - c Show the sequence of list values examined by...

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

View Full Document Right Arrow Icon
CSCI.1100 Computer Science I Quiz 9 November 19, 2007 Closed book, closed notes, no computers or calculators of any kind. Name: RCS login: Circle your lab section: (01 MR 10:00) (02 MR 12:00) (03 MR 2:00) (04 MR 4:00) (05 MR 6:00) (06 MR 10:00) (07 TF 10:00) (08 TF 12:00) (09 MR 12:00) (010 TF 2:00) 1. Consider the following list of 10 int numbers stored in a one-dimensional array: 1 15 60 66 78 80 83 85 86 99 [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] Suppose that you use binary search to search this list. a) The binary search algorithm looks for a number by repeatedly examining the value of the number in the middle of the current search interval. Show the sequence of list values examined by binary search as it searches for 83 in this list. (4 points) 78 85 80 83 1 point for each number b) Show the sequence of list values examined by binary search as it unsuccessfully searches for 18 in this list. (4 points) 78 15 60 1 point for each number plus a bonus (for any answer)
Background image of page 1

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

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c) Show the sequence of list values examined by binary search as it unsuccessfully searches for 100 in this list. (4 points) 78 85 86 99 1 point for each number d) Show the sequence of list values examined by binary search as it successfully searches for 1 in this list. (4 points) 78 15 1 1 point for each number plus a bonus (for any answer) 2. Consider algorithm performance. a) Suppose that you have two different algorithms to solve the same problem. The first of these algorithms is known to be O(n 2 ), the second O(n log n) for an input of size n. Which of these algorithms would you use? (2 points) O (n log n) 2 points b) What will be the approximate performance of the algorithms in part a if they are applied to 10,000 items? (2 points) O(n 2 ) = 10,000 * 10,000 = 100,000,000 1 point O(n log n) = 14 * 10.000 = 140,000 1 point...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

q9 sol - c Show the sequence of list values examined by...

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