Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS231 Algorithms Problem Set 4 at Wellesley College, Assignments of Algorithms and Programming

A handout for problem set 4 in the cs231 algorithms course at wellesley college. It includes problem statements, suggested readings, and animations to help students learn the material. The problems ask students to design and describe algorithms, using algorithms studied in class as black boxes where appropriate. The document also includes a grading rubric and a problem set header page.

Typology: Assignments

Pre 2010

Uploaded on 08/16/2009

koofers-user-dgs
koofers-user-dgs 🇺🇸

3.5

(2)

10 documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download CS231 Algorithms Problem Set 4 at Wellesley College and more Assignments Algorithms and Programming in PDF only on Docsity! 1 Wellesley College ◊ CS231 Algorithms ◊ October 18, 1996 Handout #19 PROBLEM SET 4 Due: Friday, October 25 Reading: CLR Chapters 9 & 10. Animations: There are a number of animations in the Animations subfolder of the CS231 folder that are helpful for learning this material. Check out: Bucket Sort, Counting Sort, and Radix Sort Suggested Problems: 9.1-1, 9.1-4; 9-2.3; 10.3-1, 10.3-3, 10.3-6, 10.3-7, 10.3-8, 10.3-9; 10- 1 Note: This problem set is different in character from the previous problem sets because all of the problems ask you to design and describe algorithms. Your descriptions should be concise, but should give enough detail that anyone familiar with CLR would know how to implement the algorithm from your description. In particular, you should liberally use algorithms we have studied as black boxes. E.g., you might describe one step of an algorithm as “use CLR’s linear order statistic algorithm to find the 17th largest element of the array” or “use heapsort to sort the array in worst-case O(n lg n) time.” However, if you modify an algorithm we have studied to do something different, you must carefully specify the steps of your algorithm . Unless specifically requested, you do not have to write pseudocode for your algorithms, but you are encouraged to do so if you find that it’s the best way to explain yourself. If you are asked to design an algorithm with a particular running time, you must justify why your algorithm has that running time. Problem 1 [20] Exercise 9.2-5 on p. 178 of CLR. Note that the notation [a..b] means the range of integers from a to b, inclusive. Problem 2 [20] Exercise 9.3-4 on p. 180 of CLR. Problem 3 [25] Exercise 10.1-1 on p. 187 of CLR. Hint: as suggested in class, imagine that the comparisons induce a tree over the elements that represents a tournament in which each node has a winner (smaller element) and a loser (larger element). Be careful that your algorithm accounts for all comparisons performed. Problem 4 [35] Do parts a, b, and c of Problem 10-2 on p. 193 of CLR. Do not do parts d and e. For part c, give pseudocode (using SELECT as a black box) and justify why your algorithm is Θ(n). The notation in this problem is somewhat confusing. Here's one way to view the problem. You are given an array A with n elements, each of which is a record with two real-numbered fields named x and w. What the problem calls xi is A[i].x and what it calls wi is A[i].w. Thus, each value x has an associated weight w that does not change throughout the problem. All the x values are distinct, but the weights are not guaranteed to be distinct. The notation ∑ xi<xk wi≤ 1 2 means "The sum of the weights of all xi such that xi < xk". It does not mean "The sum of the weights of all xi such that i < k". The other sigma sum is symmetric. 2 The weighted median of a collection is not necessarily unique. For example, if the each of the four elements 1, 2, 17, and 72 has weight 0.25, then both 2 and 17 are weighted medians. Grading: • Part a: [5] • Part b: [10] • Part c: Algorithm [15] Analysis [5] Extra Credit Problem [20[ Exercise 10.3-4 on p. 192 of CLR.
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved