University of Toronto
ECE-345: Algorithms and Data Structures
Solutions to Midterm Examination (Fall 2011)
1. (a) True. Heres the proof.
We have lg (nn ) = lg (2n lg n ).
n
n
Now, we know that n
2n lg n
22 and that lg (n) = (lg (22 ), therefore lg (n) = (

University of Toronto
ECE-345: Algorithms and Data Structures
Solutions to Midterm Examination (Fall 2009)
1. (a) False.
2
2
2
First, since n = O(2n ), 2n + n = (2n ).
limn 2
2n n2
n
So it remains to show that limn
22
2n2
=
= .
(b) Base case: n = 1 holds

University of Toronto
ECE-345: Algorithms and Data Structures
Solutions to Midterm Examination (Fall 2010)
1. (a) Yes. For example, f (n) = 1 and g (n) = |n sin(n)|, it is true.
(b) Best case is when A[0] < 0, in which case the outer loop terminates immed

University of Toronto
ECE-345: Algorithms and Data Structures
Solutions to Final Examination (Fall 2010)
1. (a)
/\
A /\
/\
/| |\
BC DE
Code: A(0), B(100), C(101), D(110), E(111).
(b) The max ow is 9.
(c) Its not solvable using the master theorem because t

University of Toronto
Department of Electrical and Computer Engineering
Final Examination
ECE345 Algorithms and Data Structures
Fall 2006
Print your name and ID number neatly in the space provided below; print your name at
the upper right corner of every

University of Toronto
Department of Electrical and Computer Engineering
Final Examination
ECE 345 Algorithms and Data Structures
Winter 2010
Print your name and ID number neatly in the space provided below; print your name at the upper right
corner of