Problem 1:
Exercise 15.4-3
Give a memoized version of LCS-LENGTH that runs in O(mn) time.
Answer:
LCS-LENGTH(X, Y)
m <- length[X]
n <- length[Y]
for i <- 1 to m do
for j <- 1 to n do
c[i,j] <- -1
end for
end for
return LOOKUP-LENGTH(X,Y,m,n)
LOOKUP-LENGTH
Problem 1-1
2.1-2
INSERTION-SORT(A) (non-increasing)
1. For j=2 to A.length
2. Key = A[j]
3. /insert A[j] into the sorted sequence A[1.j-1].
4. i=j-1
5. while i>0 and A[i] <key
6.
A[i]=A[j]
7.
i=i-1
8.
A[i+1]=key
Loop invariant:
Initialization: We start b
Exercise 15.4-5
Give an O(n2)-time algorithm to find the longest monotonically increasing
subsequence of a sequence of n numbers.
Answer:
Let S[1]S[2]S[3].S[n] be the input sequence.
Let L[i] , 1<=i <= n, be the length of the longest monotonically increas
Problem 4Data Structures
1. Hash Table
(1) A hash table generalizes the simpler notion of an ordinary array. the
average time to search for an element in a hash table is O(1).When the
number of keys actually stored is small relative to the total number of
Florida International University
School of Computer and Information Sciences
Introduction to Algorithms
COT 5407
Professor: Ning Xie
Teaching Assistant: Kianoush Gholami
ASSIGNMENT 1
Name: Gregory Murad Reis
PantherID: 5488749
Miami Florida
January 2015
1
Florida International University
School of Computer and Information Sciences
Introduction to Algorithms
COT 5407
Professor: Ning Xie
Teaching Assistant: Kianoush Gholami
ASSIGNMENT 2
Name: Gregory Murad Reis
PantherID: 5488749
Discussed with: Andrius Radv
Florida International University
School of Computer and Information Sciences
Introduction to Algorithms
COT 5407
Professor: Ning Xie
Teaching Assistant: Kianoush Gholamiboroujeni
ASSIGNMENT 3
Name: Gregory Murad Reis
PantherID: 5488749
Discussed with: And
Florida International University
School of Computing and Information Sciences
Introduction to Algorithms
COT 5407
Professor: Ning Xie
Teaching Assistant: Kianoush Gholami
ASSIGNMENT 5
Florida International University
School of Computing and Information Sciences
Introduction to Algorithms
COT 5407
Professor: Ning Xie
Teaching Assistant: Kianoush Gholami
ASSIGNMENT 4
Florida International University
School of Computer and Information Sciences
Introduction to Machine Learning
CAP 5610
Professor Ruogu Fang
ASSIGNMENT 1
Name: Gregory Murad Reis
PantherID: 5488749
Miami Florida
January 2015
1. k-NN Decision Boundaries
A)
Florida International University
School of Computer and Information Sciences
Introduction to Machine Learning
CAP 5610
Professor Ruogu Fang
ASSIGNMENT 2
Name: Gregory Murad Reis
PantherID: 5488749
Miami Florida
February 2015
1. a) Source code for online b
Exercise 6.3.3
Answer
First, let's observe that the number of leaves in a heap is n/2. Let's prove it by inducton on h.
Base: h=0. The number of leaves is n/2=n/20+1.
Step: Let's assume it holds for nodes of height h1. Let's take a tree and remove all it'
Exercise
11.1-2
A bit vector is simply an array of bits (0s and 1s). A bit vector of length m
takes
much less space than an array of m pointers. Describe how to use a bit
vector
to represent a dynamic set of distinct elements with no satellite data.
Dicti
Sorting
algorith
m
Worst
case
running
time
Average
case
Running
time
Best
Case
Running
time
Auxiliar
y space
stability
Insertio
n sort
O(n2)
O(n2)
O(n)
In-place
O(1)
Stable
Heap
sort
O(nlgn)
O(nlgn)
O(nlgn)
In-place
O(1)
Unstabl
e
Merge
sort
O(nlgn)
O(nlg
Exercise 22.3-5
To prove some properties on different types of edges:
(a) : Assume that edge (u, v) is a tree or forward edge. If (u, v) is a tree edge, then by
the definition of tree edge v is first discovered by exploring edge (u, v). If (u, v) is a
for
Florida International University
School of Computer and Information Sciences
Introduction to Machine Learning
CAP 5610
Professor Ruogu Fang
ASSIGNMENT 3
Name: Gregory Murad Reis
PantherID: 5488749
Miami Florida
March 2015
Question 1. Part 1
A)
Training Er