CSC302 2007S, Class 09: Representing Drawings Admin: * PLEASE DO YOUR BEST TO SHOW UP ON TIME! * Assigned: HW4. * Does anyone read the responses I write to your questions? * There are three readings for Monday. Make sure to respond to each of them separately. * Next Friday at lunchtime, Atul Gupta '88 or so, will be speaking about programming in the real world and about internship opportunities at his company. * Due: HW3. Overview: * Lab. /HW3 - An alternate exponentiation strategy/ (0) let accumulator = 1; // O(1) (1) while n != 0 // O(log2n) repetitions (1a) find the largest m such that 2^m <= n // O(log2n) (simultaneously find x^m) (1b) let accumlator = accumulator * x^m // O(1) let n = n - m (2) return accumulator If the two O(log2n) assumptions are correct, what is the running time? * O((log2n)^2) * log2n * log2n = (log2n)^2 /Quicksort - How did you test/ * Generate some random arrays, print them out, sort them, print the results, and check * Didn't bother - I took (and cited) Sam's code, and Sam's code is always correct. * And I have a bridge to sell you. * I modified code I wrote before, and I would not have submitted incorrect code. * Manual command line testing What technique should you be using? * One possibility: Write a procedure that checks (a) that the result is sorted and (b) that the result is a permutation of the input O(n^2ish) * Use the stuff you learned in 201