Computer Science 170 - Spring 1993 - Blum - Midterm 1

# Computer Science 170 - Spring 1993 - Blum - Midterm 1 -...

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

CS170, Midterm, Spring 1993 CS170 Spring 1993 Midterm Professor M. Blum CLOSED BOOK. CALCULATORS ALLOWED. You have two hours to complete this exam. ****DO ANY TWO OF THE THREE PROBLEMS. (Try to do all three if you can.)**** Problem #1 (Find An Element Above the Median) Give upper and lower bounds on the number of comparisons to solve the following problems: INPUT: An array A=[a 1 ...a N ] of real numbers. N = even integer. The array is NOT sorted. OUTPUT: An element a 1 contained in A that is greater than the MEDIAN, where the median is the biggest element in the bottom half. EXAMPLE: A = [1, 5, 3, 6]; MEDIAN = 3; RETURN 5 or 6. Use the decision tree model of computation. (Each comparison counts 1 step.) Make your bounds as tight as you can make them, but no tighter. Problem #2 (Celebrity Problem) DEFINITION: A celebrity is someone whom everyone knows, but who knows no one (else). THE PROBLEM: You are to determine if a party of N persons, N >= 2, has a celebrity by asking questions of the form "Do you know that person over there?" STEPS: Each question counts one step. All other computations are free.

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.

{[ snackBarMessage ]}

### Page1 / 2

Computer Science 170 - Spring 1993 - Blum - Midterm 1 -...

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

View Full Document
Ask a homework question - tutors are online