This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: UofToronto–ECE 345–Fall, 2010 1 Homework 2 Homework 2 ECE 345 Algorithms and Data Structures Fall Semester, 2010 Due: October 12, 2010, at 2pm in the drop box labeled ECE345 in the SF basement down the hall from the ECE undergraduate office (the corridor that connects SF to GB) • All page numbers are from 2001 edition of Cormen, Leiserson, Rivest and Stein. • For each algorithm you asked to design you should give a detailed description of the idea, proof of algorithm correctness, termination, analysis of time and space complexity. If not, your answer will be incomplete and you will miss credit. You are allowed to refer to pages in the textbook. • Do not write C code! When asked to describe an algorithm give analytical pseudocode. • Staple your homework properly. Use a stapler; do not use glue or other weird material to put it together. If you are missing pages, we are not responsible for it but you are! • Write clearly , if we cannot understand what you write you may not get credit for the question. Be as formal as possible in your answers. Don’t forget to include your name(s) and student number(s) on the front page ! ———————————————————————————————————— 1. [Search, 15 points] Devise a Θ( n log n ) algorithm, which, given a set S of n nonzero real numbers and another real number x , determines whether or not there exists two elements in S whose product is exactly x . 2. [Sorting, 10+10 points] George thinks he has a new sorting algorithm. The pseudocode for his MySort algorithm is given below. The input is a list A [1 ...n ] of n numbers, where n is a power of 2. (a) Analyze the running time of MySort. (b) Does the algorithm sort correctly? If yes, argue why. If not, give a counterexample....
View
Full
Document
This note was uploaded on 11/09/2010 for the course ECE 345 taught by Professor Veneris during the Fall '10 term at University of Toronto.
 Fall '10
 Veneris
 Algorithms, Data Structures

Click to edit the document details