This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Design and Analysis of Algorithms CSE 101 Sample Midterm Questions 1. Write a recursive algorithm that sorts a list of n items by dividing them into three sublists of n/ 3 items, sorting each sublist recursively and merging the three sorted sublists. Analyze your algorithm, and determine its time complexity. Make sure that you formulate the appropriate recurrence relation and present its solution. Present a high level description of the algorithm followed by pseudo code. Dont write detailed code. 2. Let S be an unsorted array of n distinct integers. Give an algorithm that finds the pair of elements x , y in the array S such that x 6 = y and  x y  is minimized. Your algorithm must run in O ( n log n ) worstcase time. 3. You are given all of the book checkout cards used in the campus library duing the past year. Design an efficient algorithm for determining how many distinct people checked out at least one book. For each book, there is a checkout card bearing the ID of the book andat least one book....
View
Full
Document
This note was uploaded on 03/16/2010 for the course CSE 101 taught by Professor Staff during the Winter '08 term at UCSD.
 Winter '08
 staff
 Algorithms, Sort

Click to edit the document details