Presentation is loading. Please wait.

Presentation is loading. Please wait.

COT 5405 Spring 2009 Discussion Session 3. Introduction Our weekly discussion class are like organized TA office hours. Here we encourage students to.

Similar presentations


Presentation on theme: "COT 5405 Spring 2009 Discussion Session 3. Introduction Our weekly discussion class are like organized TA office hours. Here we encourage students to."— Presentation transcript:

1 COT 5405 Spring 2009 Discussion Session 3

2 Introduction Our weekly discussion class are like organized TA office hours. Here we encourage students to come with their problems and questions about class and book. Rather than doing One-to-one discussion like regular TA office hours, we do group discussion to solve problems. We mostly discuss about proofs and problems presented in regular lecture classes, but in more details. To help better understanding of them. Again, we encourage students to come to Tuesday’s discussion class more frequently. Unfortunately no video is available for EDGE students. As this is not lecture, just like TA office hour.

3 Problem 1 In the algorithm SELECT, the input elements are divided into groups of 5. Will the algorithm work in linear time if they are divided into groups of 7? Argue that SELECT does not run in linear time if groups of 3 are used.

4 Problem 2 Let X[1.. n] and Y [1.. n] be two arrays, each containing n numbers already in sorted order. Give an O (lg n)-time algorithm to find the median of all 2n elements in arrays X and Y.

5 Problem 3 Show that the second smallest of n elements can be found with n + ⌈ lg n ⌉ - 2 comparisons in the worst case. (Hint: Also find the smallest element.)

6 Problem 4

7 Problem 5 You are the TA for a class with an enrollment of n students. You have their final scores (unsorted), and you must assign them one of the k available grades (A, B, C etc.). The constraints are (assuming n is a multiple of k): –Exactly (n/k) students get each grade (for example, if n = 30, and k = 3, i.e. the available grades are {A,B,C}, then exactly 10 students get A, 10 get B, and 10 get C) –A student with lower score doesn’t get a higher grade than a student with a higher score (however, they may get the same grade) –Assuming that each student received a different score, derive an efficient algorithm and give its complexity in terms of n and k.

8 Problem 6

9 Problem 7

10 Problem 8 Consider a list of size n, which has at most log n distinct numbers, the rest being repetitions of those numbers. Design an algorithm to sort this list in O(n log log n) time. (Hint: First partition the list into n / log n lists of size log n and use a merge sort-like strategy).

11 Problem 9

12 Comments Problems 1,2,3,4,5,6(a) and 8 were discussed in discussion session 3. We do not plan to provide any written solution to these problems. Students are welcome to send us email with solutions of these problems. We can verify your solutions.


Download ppt "COT 5405 Spring 2009 Discussion Session 3. Introduction Our weekly discussion class are like organized TA office hours. Here we encourage students to."

Similar presentations


Ads by Google