CSci 5302
HW1 v2
Due: Feb. 09 2010
In the last 2 problems, hand in a written description of how you set up and solved the problem.
You are not required to hand in the computer source code, but you sh
Algorithm
Select a pivot
Move elements smaller than pivot to left, elements larger than pivot to right
Recursively sort left side and right side
Methods of choosing pivot:
Original method: Left-m
GRAPHS
Map Coloring Problem:
-Suppose you are trying to pick colors for a map
-If two countries are next to each other, they should have different colors
-How do you pick the colors?
A natural repr
SORTING
Goal of Sorting: Given an unsorted array, output a sorted array.
Main questions to be answered for any algorithm:
Worst case running time? When does this happen?
Average case running time
CSci 5302
HW2
Due: Feb. 23 2010
Hand in a written description of how you set up and solved each problem. You are not required
to hand in the computer source code, but you should describe the algorith
b. Finding Majority Element problem
Given an unsorted array of objects (not necessarily integers) with length n
You cannot assume that the objects are sortable
A majority element is an object that
DIVIDE AND CONQUER
A divide-and-conquer algorithm has three main steps:
1. Break the problem into smaller sub-problems
2. Recursively solve the sub-problems
3. Combine the sub-problem solutions to so
Big-O Notation
Let us take an example,
3n+1 = O(n2). Let us check if the Big-0 condition holds and try to find out the value
of M
and xo.
Try putting in the value of n as 0 and compare both the functi
Big - Q Notation
Given two functions f(x) and g(x), then f(x) =Q (g(x) if and only if
(Soundarajan S., 2017),
f(x) = O(g(x) and
g(x) = O(f(x).
If a function is a Big-Q of another function that means
Graph Representation:
1. Adjacency Matrix:
a. Suppose there are n = |V| vertices
b. Create an n x n matrix A
For n vertices, adjacency matrix will store n2 values. Once created, it takes O(1) time to
Real life applications of graph:
Graphs are nothing but connected nodes (vertices). So any network related,
routing, finding relation, path etc. related real life applications use graphs.
Connecting
Algorithm:
Iterate through the array A
At each element A[i], figure out where in A[0:i - 1] to place A[i]
Shift appropriate elements from A[0:i 1]
Insert A[i]
Running time of Algorithm is O(n2
)
Quick sort Algorithm
Select a pivot
Move elements smaller than pivot to left, elements larger than pivot to right
Recursively sort left side and right side
Methods of choosing pivot:
Original met
3. In the Grand Tour problem, you are given a list of n cities along with their
pairwise distances (i.e., you know the distance between every two cities). All
distances are positive and symmetric (the
Algorithm:
1. Find the middle point to divide the array into two halves
2. Call mergeSort for first half
3. Call mergeSort for second half
4. Merge the two halves sorted in step 2 and 3
Using Master
Algorithm:
Find smallest in list
Swap smallest element with first element
Repeat with second-smallest, etc.
Running time of Algorithm is O(n2
) as work being done per iteration is O(n) and there
a
Problem 1: Suppose that in some country, there is a set of cities C1; :;Cn.
The water for these cities all comes from the same lake. Some pairs of cities
are connected by water pipes (for example, C1
Problem 1: Suppose you are trying to navigate a set of roads to get from
point A to point B. Assume that the roads are on a grid. All roads are
one-way roads, and point either straight north or straig
Problem 4: Suppose you are trying to cross a river. You begin on the left
side of the river and are trying to get to the right side. There is a set of n
stones R1; :;Rn that you can step on to help yo
Big - W Notation
We define Big - W as:
Let (n) and (n) be two functions (Cormen T., Balkcom D., 2014)
We say that () = () if
an integer 0 and a positive constant such that
|()| |()|, 0.
LHopitals Rule
When applying the limits like mentioned in the above section, there will
be scenarios where both
the functions will tend to towards or 0. In this case, to solve the limit
we apply the L
CSci 5302
HW3 v.2
Due: 23 Mar 2010
Do this assignment in pairs (groups of two students).
Hand in only one copy for each pair, with both names on it.
This question should be done by a Matlab function
CSci 5302
HW4
Due: 1 Apr 2010
1. This problem requires that you write a program in any language you like. The program is not
very big, but can behave in dierent ways. You should not use any pre-writte
CSci 5302
HW5
Due: 22 Apr 2010
Do this homework in pairs, or do part of the homework individually. Even if you do the homework
individually, you should understand how to do the remaining problems.
1.
CSci 5302
HW6 Due: 06 May 2010
This homework should be done in groups of 2 or 3 people. If you wish to work in a group
of 3, then you must also do the extra problem indicated.
In the following probl
Name+Email-ID:
CSci 5302 Quiz 0 Spring 2017
Do this using the calculator in your cell phone.
1. Identify your floating point environment: type of cell phone/table/computer, software
or app used to car
CSci 5302
HW2
Due: Feb. 23 2017
Hand in a written description of how you set up and solved each problem. Hand in the MATLAB
source code as well as a description of the algorithm, which should refer t
CSci 5302
HW1
Due: Jan. 31, 2017
In all problems clearly identify with a box what your answers are. For every problem show the
intermediate results used to obtain the solution, even if you could obta
CSci 5302
Midterm 1 practice
Spring 2017
Open book/notes. No electronics. Any device with any wireless communication capability
must be completely turned off.
Total of 100 points over 2 pages. includi
Name+Email-ID:
CSci 5302 Quiz 1 Spring 2017
Let p(x) = x4 + 7.6x3 + 21.66x2 + 27.436x + 13.0321. We address the issue of determining
the accuracy of computed roots of this polynomial. For this quiz, y