hw2 - UofTorontoECE 345Fall, 2010 1 Homework 2 Homework 2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: UofTorontoECE 345Fall, 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. Dont 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 non-zero 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 counter-example....
View Full Document

Page1 / 3

hw2 - UofTorontoECE 345Fall, 2010 1 Homework 2 Homework 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online