Homework 1: Solutions
COMP 251 Autumn 2012
Instructor:Prakash Panangaden
1. Give an algorithm to nd the largest and the smallest number in an unordered set of n numbers. What
is the running time of your algorithm? I want an answer in the form k n + o(n) w
Mid-Term Exam 1 Solutions
COMP 251 Algorithms and Data Structures
Tues. Feb. 4, 2014
Prof. Michael Langer
1)
a)
GRADING SCHEME: 2 points total. We have 0.5 for inserting the 45 at the correct place. This
makes the tree unbalanced. The first rotation gets
COMP 251A 2014, Assignment 4
Due Thursday December 4th 2014
[10%]
[15%]
[15%]
!
[20%] Problems 26-1: Escape problem
An n n grid is an undirected graph consisting of n rows and n columns of vertices, as
shown in Figure 26.11. We denote the vertex in the it
[20%]
COMP 251A 2014, Assignment 1
Due Monday September 29th 2014
1. Read Chapter 1. Solve Exercise 4.
!
!
[10%] 2. Read Chapter 2.
Prove that if
limn f(n)/g(n) = 0
then f(n) is O(g(n) but g(n) is not O(f(n).
3.Solve Exercises 1-3-5-6.
[15%]
COMP 251A 2014, assignment 3
Due Wednesday Nov 12th 2014
[10%]
!
Note : It turns out that different domains for the xis yield very different solutions. So
lets explore that in details. You may choose one of two versions of this question as listed
below. I
Computer Science COMP-251B
Midterm, Feb 16, 2011, 16:05-17:25.
O P E N B O O K S / O P E N N O T E S
1)
a) Write a recursive algorithm such that the related time recurrence cannot be
solved with the Master Theorem.
b) Write two recurrences such that their
COMP-251B
Data Structures and Algorithms
Faculty of Science Final Examination
Computer Science 308-251B Data Structures and Algorithms
Examiner: Prof. Claude Crpeau Associate Examiner: Lecturer Martin Courchesne
Date: April 20, 2005 Time: 14:00 17:00
INST
COMP 250 Winter 2009
lecture 30
March 27, 2009
I began this lecture by reviewing some basic terms about maps and hashing including: key, value, and hash function, hash code, hash value, collision, separate chaining. the load factor of a hash table is the
COMP-251B
Data Structures and Algorithms
Faculty of Science
Final Examination
Computer Science COMP-251B
Data Structures and Algorithms
Examiner: Prof. Claude Crpeau
Associate Examiner: Prof. Clark Verbrugge
Date: April 18, 2011
Time: 14:00 17:00
INSTRUCT
COMP-251B
Data Structures and Algorithms
Faculty of Science
Final Examination
Computer Science COMP-251A
Data Structures and Algorithms
Examiner: Prof. Claude Crpeau
Date: Dec. 15, 2014
Associate Prof. Prakash Panangaden
Examiner:
Time: 9:00 12:00
INSTRUC
Computer Science COMP-251B
Midterm, Feb 17, 2005, 14:35-15:55.
O P E N B O O K S / O P E N N O T E S
1)
Let
T(n) =
1
T(
if n=1
n/5
) + T(
n/4
) + T(
n/3
) + O(n)
if n>1
Prove by constructive induction that T(n) is O(n).
2)
Explain how to make quick-sort r
Computer Science COMP-251B
Midterm, Feb 14, 2008, 14:35-15:55.
O P E N B O O K S / O P E N N O T E S
1)
Let
T(n) =
1
T(
if n=1
n/6
) + 2T(
n/3
) + O(n)
if n>1
Prove by constructive induction that T(n) is O(n).
2) Exercises 9.3-5
Suppose that you have a bl
Computer Science COMP-251B
Midterm, Feb 18, 2010, 14:35-15:55.
O P E N B O O K S / O P E N N O T E S
1)
Let
T(n) =
1
if n=1
3T( n / 4 ) + T( n / 8 ) + O(n)
if n>1
Prove by induction that T(n) is O(n).
2) from Exercises 7.4-5
The running time of quicksort
COMP-251B
Data Structures and Algorithms
Faculty of Science
Final Examination
Computer Science 308-251B
Data Structures and Algorithms
Examiner: Prof. Claude Crpeau
Associate Examiner: Prof. Patrick Hayden
Date: April 30, 2010
Time: 09:00 12:00
INSTRUCTIO
COMP 251 2015, Assignment 1
Due Thursday October 1st 2015
[20%]
1. Read Chapter 1. Solve Exercise 4.
!
!
[10%]
2. Read Chapter 2. Prove that if
limn f(n)/g(n) = 0
then f(n) is O(g(n) but f(n) is not (g(n).
[15%]
3.Solve the following Exercises
a) 99n
b)
COMP 251 2016, Assignment 4, due
Monday December 5th 2016 23:59
1. Maximum Deadline
[10%]
[10%]
[5%]
[5%]
[10%]
2. Critical edges
3. Blood Bank
[10%]
[10%]
10
4. Escape Problem (26-1)
An n n grid is an undirected graph consisting of n rows and n columns
COMP 251 Fall 2016, HW-3
Due Wednesday Nov 16th 2016, 23:59:59
[10%]
1) RBT-Sorting.
The input is a sequence of n integers with many duplications, such that the number
of distinct integers in the sequence is O(log n). Design a sorting algorithm (based
on
1/17/2012
Homework 10.19
13.5%
~2.35%
34% 34%
~0.15%
Students randomly select
16 stocks and calculate
the proportion of
13.5%
successes (stocks which
~2.35%
rose) for a day. The
~0.15% population proportion of
successes is p = .5 . The
center and spread o
COMP 251 Winter 2014 Mid-Term Exam 2 (solutions)
1.
a) Yes, it is bipartite. cfw_A, C, E, G, I and cfw_B, D, F, H are two sets such that all edges are crossing edges.
b) The stable matching is (1, 1), (2, 3), (3, 2).
The only rejection occurs when the mat
COMP 251 Algorithms and Data Structures
Winter 2014
Final Exam Solutions
1)
a)
b)
Grading for (a) 2 points: 0.5 for giving a binary search tree, 0.5 for inserting everything first and then
balancing afterwards with rotations, 0.5 for balancing as you inse
Challenging Problem 2 (Bonus: 2 points in the final examination)
Suppose you are a consultant for the networking company CluNet, and
they have the following problem. The network that they are currently
working on is modeled by a connected graph G=(V, E) w
College of Computing and Information Technology
Lecturer:
Dr. Nahla Belal
Course:
Computing Algorithms
TA:
Eng. Mohammad Badawy
(CS312)
Sheet 4
1. Design an efficient algorithm to solve the following scheduling problem. Provide a pseudocode and a worst ca
COMP 273 Fall 2016 Assignment 3
Julia and Mandelbrot sets in MIPS
Due: 11:30 pm, Wednesday 9 November, 2016
1
Introduction
The term fractal was introduced by French mathematician Benot Mandelbrot in the mid-1970s to refer to strange
and beautiful mathemat
Comp 251: Algorithms and Data Structures
Assignment 1: Solutions
1. The Master Theorem.
These recurrences are of the form T (n) = a T (n/b) + (nd ). Recall we have
three cases depending upon the relative values of a and bd .
(a) t(n) = 8 t( 31 n) + n2 . H
Comp 251: Algorithms and Data Structures
Assignment 3: Solutions
1. Money Changing.
(a) Let f (n) denote the fewest number of coins needed to add up to a total
value of n cents. Then we have the following recurrence:
f (n) = 1 + min f (n di )
1ik
To see t
Exercises 1
COMP 423
Jan. 2008
1. Is it possible to construct a prefix code with six symbols that have codeword lengths i =
cfw_5 , 3 , 4 , 2 , 1 , 4. If so, then construct one. If not, then why not?
2. Consider an alphabet with three symbols where
p(A1 )
COMP 251 2016, Assignment 1
Due Wednesday September 28th 2016
[20%]
1. Read Chapter 1. Solve Exercise 4.
!
!
GS Men-optimal
Initialize each person to be free.
while (some man is free and hasn't proposed to every woman)
cfw_
Choose such a man m
w = 1st wo
COMP 251 2016, Assignment 1
2. Either prove the following statement or exhibit a counter-example.
The solutions produced by both algorithms are equal
if and only if
this is the only solution to the input instance.
Two things have to be proved here:
A) (th