Vous êtes sur la page 1sur 9

Danny Hocka Lugo

CSCE 586 HW #5

Page |1

1. Each problem is worth 5pts unless otherwise stated. Blank answers get 0 points.
a. Provide a concise definition of algorithm.
A tool for solving a well-specified computational problem.
b. List five problem types solved using algorithms and provide a short description of each.
Sorting problems arranging the inputs in a certain way
Searching problems trying to find a solution from a big set
Managing and manipulating large volume of data
Public Key Cryptography and Digital Signatures
Optimization Problems - Allocating resources in the most beneficial way
Graph problem - Finding the shortest route to take between places
c. What are the (nine) things to consider when solving problems with algorithms (and let us not
forget #10, because George Carlin says you have to have 10 items to be official).
i. Understand the problem what would the input and outputs be
ii. Computing Resources what are the constraints
iii. Decide Exact / Approximate Solutions can the exact solution be found does it take
too long.
iv. Data Structures help with the efficiency of the algorithm
v. Choose Design Approach more than one way to skin a cat, not that I have skinned a
cat before
vi. Specify the Algorithm Needs to be unambiguous and procedural
vii. Algorithms Correctness many methods to choose to prove
viii. Analyze the Algorithm exploring efficiency and running times
ix. Implement the Algorithm Code it up
x. Testing algorithm - especially the edge cases

d. If an algorithm is (f(n)), then it is necessarily


This algorithm has tight bounds. Which means that we can expect a certain performance
(f(n)) to within a constant factor.
e. List and provide a brief description of each algorithm analysis notation type (there are five of
them), state if they are asymptotically tight bounds or not.
-notation (Big Omega) - Asymptotic lower bound, can be tight
-notation (Big Theta) - Asymptotically tight
O-notation (Big Oh) - Asymptotic upper bound kinda like worst case, can be tight
o-notation (Little Oh) - Not asymptotically tight upper bounds
-notation (Little Omega) - Not asymptotically tight lower bounds

Danny Hocka Lugo


CSCE 586 HW #5

Page |2

f. (10 pts) Given the following recurrence relationships, identify the type of problem it
represents. If you feel a recurrence is does not fit a specific problem type, then provide a
brief explanation of why you believe this is so.
i. T(n) = T(sqrt(n)) + 1
Decrease and conquer variable size decrease
ii. T(n) = 3T(n/12) + (n)
Divide and conquer
iii. T(n) = T(n/2) + 1
Decrease and conquer decrease by constant factor
iv. T(n) = T(n-1) + o(n)
Decrease and Conquer- constant decrease
v. T(n) = 2T(sqrt(n)-1) + O(logn)
Divide and conquer- divide in 2 parts then decrease by constant and variable sizes

Danny Hocka Lugo


CSCE 586 HW #5

Page |3

2. Recurrence, Proofs, and Math Stuff (50pts).


a. (15 pts) Let T(n) = 3T(n/3) + 5n. Compute T(n), i.e., solve the recurrence. If you can not find
a value for theta, then settle for a series that gives T(n).

Danny Hocka Lugo


CSCE 586 HW #5

Page |4

b. (15 pts) Suppose you have a divide and conquer algorithm that divides a problem into two
sub problems of unequal size, such that the its recurrence equation is:
T(n) = T(n/2) + T(n/4) + 1
i. (5 pts) Draw a tree that shows the operation of the algorithm

Danny Hocka Lugo


CSCE 586 HW #5

Page |5

ii. (10 pts) Can you find a tight bound (theta) on its running time? If not, can you find
the upper and lower bounds on the running time?

c. (10 pts) Prove by induction that:

i3
i 1

n 2 n 1
4

Danny Hocka Lugo


CSCE 586 HW #5

Page |6

d. (10 pts) Evaluate the following summations:


i

1
i. (5 pts)
i 0 7

x 2
ii. (5 pts)
i 1 5

i 1

assume x2 < 5

3. Design Problem (50 pts) Choose one of the two following design problems.
a. Design Problem #1: A simple competitive algorithm called Learning Vector Quantization is a
supervised learning algorithm; you assign classification resources (prototype vectors) to each
class and modify those resources based on the known class labels of the input samples. The
LVQs predecessor is called the Self-Organizing Feature Map (also called Kohonens Self
Organizing Map, or simply Self-Organizing Map SOM for short). The SOM is an
unsupervised learning algorithm. That is to say, it does not utilize class label information
during the learning process (at least not in the basic form of the algorithm). The SOM is a
particularly powerful clustering algorithm that projects the high-dimensional probability
distribution function of the data of interest onto a two-dimensional fixed lattice (its a grid).
The SOM works by first defining an rSOM x cSOM rectangular lattice (often rSOM=cSOM, but there
is no restriction to do so) where each lattice point is called a processing element (PE). Each
PE in the 2D grid has associated with it a d-dimensional vector, the same number of
dimensions as the data. The SOM preserves the ordering relationships of the highdimensional data on this 2D lattice by way of a neighborhood function. In the original SOM
by Kohonen, this neighborhood function is a continuous function (an exponential or

Danny Hocka Lugo


CSCE 586 HW #5

Page |7

Gaussian function in its original definition) that is maximum when located at the winning PE
on the 2D lattice:

d PESOM , PEBMU

h PESOM , PE BMU , e

where PESOM is the lattice location (i.e., (i,j) location on the rSOM x cSOM lattice) of the PE that
is a neighbor of the winning prototype vector and PEBMU is the lattice location of the winning
prototype vector called the best matching unit (BMU), is the size of the neighborhood.
Assume your input is a d-dimensional image with rI rows and cI columns. The process is to
take an input at random and compute the distance between it and the weight vector associated
with each PE (i.e., d(x(i,j),PESOM). The PESOM prototype vector yielding the smallest distances
is the winner (i.e., BMU). Updates to PEs (affected by the neighborhood function) are as
follows:
w PE SOM new w PE SOM old k h PE SOM , PE BMU , x i , j w PE SOM old
where (k) is a monotonically decreasing learn rate, x(i,j) is the input sample, and w(PESOM)
is the weight associated with the PE to be updated (note that PESOM can be PEBMU when
updating the BMU), and w(PEBMU) is the weight vector associated with the BMU.
i. Assume you will iterate the learning process K times. Write the neighborhood
function such that it decays over time by incorporating it into the Gaussian function.
Is it necessary to use ? Come up with a learn rate that is monotonically decreasing.
What did you choose and why? Plot (using Matlab, excel, or your favorite plotting
applications) both the neighborhood and learn rate functions versus time. How else
can you decrease the learn rate?
ii. Choose an appropriate distance metric and provide a description (math or pseudo
code is appropriate) of that metric. Why did you choose this metric? Could you use
something else?
iii. Given the definition of the neighborhood function, how many prototypes are updated
after the BMU is located?
iv. Provide a pseudo code description of the SOM algorithm. Add comments and
sketches as appropriate. What design strategy did you follow? What is the basic
v. operation? What are the variables involved in defining the computational complexity?
Provide a description of the running time of your algorithm based on these variables.
b. Design Problem #2: We talk about an algorithm being in-place, and in many applications, it
is un-necessary (depending on the size of the problem, processing resources available, etc).

Danny Hocka Lugo


CSCE 586 HW #5

Page |8

Recall that an in-place algorithm should use a minimal amount of memory for storing
variables, but should not create duplicates of the data arrays, or additional arrays of the same
length that hold counters, etc. Another important property is that of stability: elements in the
array with the same key should remain in their relative location after the sorting has
completed.
The application is that of sorting track information in time-critical C4I platforms, in
particular the Modular Control Equipment (MCE) and the often associated TPS-75 RADAR.
Systems used for the track and ID of aircraft have a track database that contains extremely
useful information such as the track number, track identification (e.g., friendly, etc), latitude
and longitude, and track altitude (among other things). We are interested in sorting, at
regular time intervals (say m*t), all tracks based on their distance from some waypoint W,
which has associated with it lat/long coordinates and an altitude.
Your task is to design an in-place sorting algorithm that is stable and that performs memory
swaps without using additional memory locations. The algorithm must be appropriate for
the application at hand. To this end, provide the following:
i. First specify (e.g., using math or pseudo code, or both) how you can swap two
memory locations without using temporary storage. Assume your two memory
locations of interest are A and B. A couple of notes here: Although it is recognized
that this method is slower than using a temporary storage space on newer
architectures, it is not the case for older architectures (those that our AWACS, MCE,
missile defense systems, and many of the Navys ballistic trajectory systems are
based on!) You can not assume you have an efficient swap instruction that is part of
the instruction set available to you as is the case with more modern processors (more
on this after the turn-in of the exam).
ii. Choose an appropriate distance metric and provide a description (math or pseudo
code is appropriate) of that metric. I dont expect your distance metric to be perfect,
but provide justification based on the problem description (e.g., say your radar has a
200 mile radius and a 30K+ ft height ceiling). Hint: pictures are useful.
iii. Choose a sorting algorithm that is appropriate for this problem (consider the
application and the problem description). You can use popular sorting algorithms as a
basis for your algorithm (algorithm description is the next section, no need to specify
it here). Clearly explain (in words) why you chose the algorithm you chose.
iv. Provide a pseudo-code description for the modified sorting algorithm based on what
you chose as a base sorting algorithm in Part 3 and assume you have functions that
are used to specified each of the additional algorithms above (the swapping algorithm
and the distance metric). (NOTE: you can add comments and sketches to help clarify
if you find your algorithm hard to explain). What design strategy does it follow?
Provide the recurrence relation based on the design strategy you chose. What is the

Danny Hocka Lugo


CSCE 586 HW #5

Page |9

running time of your system (NOTE: depending on the algorithm you chose, it may
be useful to provide all or one of the following: best case, worst case, average case).