Final-Spring05-Solutions - University of Waterloo...

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

View Full Document Right Arrow Icon
SE240 Final Exam, Spring 2005 Page 1 of 16 University of Waterloo Department of Electrical and Computer Engineering SE 240 Algorithms and Data Structures Spring 2005 Final Examination Instructor: Ladan Tahvildari Date: August 4, 2005 Time: 4:00 p.m. to 6:30 p.m. Duration: 2.5 hours Type: Closed Book Instructions: There are 7 questions. Answer all 7 questions. The number in brackets denotes the relative weight of the question (out of 100). If information appears to be missing from a question, make a reasonable assumption, state it and proceed. Write your answers directly on the sheets. If the space to answer a question is not sufficient, use the last (overflow) page. When presenting programs, you may use any mixture of pseudocode/C++/Java constructs as long as the meaning is clear. Name Student ID Question Mark Max Marker 1 15 2 7 3 8 4 10 5 25 6 25 7 10 Total 100
Background image of page 1

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

View Full DocumentRight Arrow Icon
SE240 Final Exam, Spring 2005 Page 2 of 16 Name: Student ID: Question 1: Algorithm Analysis [15] Part A [8]. You are given a set of n identical sealed boxes, 1 n of which contain one donut and one of which is empty. For convenience, you may assume that k n 2 = for some integer k . To help you find the empty box, you have a balance. At which weighing, you place two sets of boxes on the balance and determine which set is heavier. i) Describe an algorithm to find the empty box which uses ) (log n O weighings. a) Divide boxes into two sets of equal size b) Weigh the sets against each other c) Report (recursively) with lighter set ii) Give a recurrence and solve it to show your algorithm runs in ) (log n O . + = = 2 1 ) 2 / ( 1 0 ) ( n if n W n if n W a=1, b=2 1 0 1 log 2 = = n n f(n)=1=O(1) Then, W(n)=logn
Background image of page 2
SE240 Final Exam, Spring 2005 Page 3 of 16 Name: Student ID: Part B [7]. Give asymptotic upper and lower bounds for ) ( n T in the following recurrence. Assume that ) ( n T is constant for sufficiently small n . Make your bounds as tight as possible, and justify your answers. n n n T n T lg ) 9 ( 81 ) ( 4 + = 9 ; 81 = = b a 2 81 log log 9 = = a b 2 log n n a b = n n n f lg ) ( 4 = Case 3 of the Master Method ) ( ) ( ) ( 2 log ε + + = = n n n f a b if 1 = Regularity Condition ) ( ) / ( n f c b n f a p for some constant 1 p c ) log ( ) log ) 81 ( ( 81 4 4 4 n n cf b n n f p holds here for 99 . 0 = c
Background image of page 3

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

View Full DocumentRight Arrow Icon
SE240 Final Exam, Spring 2005 Page 4 of 16 Name: Student ID: Question 2: Hashing [7] Consider the following hash table of size 13. 0
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

Final-Spring05-Solutions - University of Waterloo...

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

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