Sorting (II)
Dr. Antonio L. Bajuelos
Note: The most of the information of these slides was extracted and adapted from Weisss book, Data
Structures and Algorithm Analysis in Java". They are provided for COP3530 students only. Not to be
published or publicl
Hashing
Dr. Antonio L. Bajuelos
Note: The most of the information of these slides was extracted and adapted from Weisss book, Data
Structures and Algorithm Analysis in Java". They are provided for COP3530 students only. Not to be
published or publicly dis
Sorting (I)
Dr. Antonio L. Bajuelos
Note: The most of the information of these slides was extracted and adapted from Weisss book, Data
Structures and Algorithm Analysis in Java". They are provided for COP3530 students only. Not to be
published or publicly
Union-Find
Data Structure
Dr. Antonio L. Bajuelos
Note: The most of the information of these slides was extracted and adapted from Weisss book, Data
Structures and Algorithm Analysis in Java". They are provided for COP-3530 students only. Not to be
publis
Minimum Spanning
Tree
Dr. Antonio L. Bajuelos
Note: The most of the information of these slides was extracted and adapted from Weisss book, Data
Structures and Algorithm Analysis in Java". They are provided for COP3530 students only. Not to be
published o
Priority Queues
(Heaps)
Dr. Antonio L. Bajuelos
Note: The most of the information of these slides was extracted and adapted from Weisss book, Data
Structures and Algorithm Analysis in Java". They are provided for COP3530 students only. Not to be
published
Bellman-Ford
Algorithm for
Shortest Paths
Dr. Antonio L. Bajuelos
Note: The most of the information of these slides was extracted and adapted from Weisss book, Data
Structures and Algorithm Analysis in Java". They are provided for COP3530 students only. N
Assignment/Homework #1
COP-3530, Summer C 2017
Rules & Instructions:
Due date: Wed, May 24, 2017 at 3 pm (Eastern Time)
This assignment has 3 problems.
The assignment/homework will be submitted by email to
Your submission must be a ZIP file (not RAR forma
1. Defining the given literals:
Let C = Sophia is a college professor,
U = Sophia is a university professor,
D = Sophia has an M.S degree,
S = Sophia is smart
Claim: (C U) (C D) (U D) S) (S C)
In order to prove the claim, Ill try to prove that the negatio
1. Defining the given literals:
Let C = Sophia is a college professor,
U = Sophia is a university professor,
D = Sophia has an M.S degree,
S = Sophia is smart
Claim: (C U) (C D) (U D) S) (S C)
In order to prove the claim, Ill try to prove that the negatio
Assignment/Homework #1
COT-3541, Spring 2017
(proposed solutions)
Question #1
Tom, Ann and John find themselves trapped in a dark and cold dungeon. After a quick
search the boys find three doors, the first one red, the second one blue, and the third one
g
COT-5407-U01: Introduction to Algorithms
Florida International University
Assignment #1
Monday, February 1, 2016
Problem Set 1
This Problem Set as a warm-up is intended to help students master the course material in Part I: Foundation.
You are responsible
COT-5407-U01: Introduction to Algorithms
Florida International University
Assignment #2
Friday, February 19, 2016
Summary Report
Preparing a summary report is an efficient way for learning the literature thoroughly, and will bring you
convenience to fast
COT-5407-U01: Introduction to Algorithms
Florida International University
Assignment #3
Friday, March 11, 2016
Problem Set 3
This Problem Set is intended to help students master the course material in Part III: Data Structures. You
are responsible for the
COT-5407-U01: Introduction to Algorithms
Florida International University
Assignment #4
Friday, April 08, 2016
Problem Set 4
This Problem Set as a warm-up is intended to help students master the course material in Part VI: Graph Algorithms. Students are r
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
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 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
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
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
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
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
Michael Kaiser
Assignment 2
Comp 510
Fall 2012
16.1-1
Give a dynamic-programming algorithm for the activity-selection problem, based on the
recurrence (16.2). Have your algorithm compute the sizes c[i, j] as defined above and also
produce the maximum-size
Theorem 21.1 : Using the linked-list representation of disjoint sets and the weightedunion heuristic, a sequence of m MAKE-SET, UNION, and FIND-SET operations, n of
which are MAKE-SET operations, takes O(m + n lg n) time.
Proof We start by computing, for
06 1A927407
16.1-2
Suppose that instead of always selecting the first activity to finish, we instead select
the last activity to start that is compatible with all previously selected activities.
Describe how this approach is a greedy algorithm, and prove