The run time of this algorithm is given by the recursive equation
Given a sequence
X = <x1, x2, ., xn>
a sequence of length k
Z = <z1, z2, ., zk>
is a subsequence if there exists a strictly increasing set of indicies <i1, i2, ., ik> such
that
In other wor
The question now is how do we construct a hashing function that satisfies the desired
property of simple uniform hashing? The answer to this question is usually dependent
on the distribution of the keys (which for a limited number can simply be a lookup
t
Directed Graph (digraph)
In a directed graph, the edges are represented by ordered pairs of vertices (u, v) and
shown diagramatically as directed arrows (a vertex may be connected to itself via
a self-loop).
An edge (u, v) is incident from (i.e. leaves) u
Chain Operations
INSERT(T, x) - place new element x at the head of list h(k) - O(1) assuming element is
not in list, otherwise need to search list
DELETE(T, x) - delete element x from list at T(h[x.key]) - O(1) since x would contain
pointers to the next a
Birthday Paradox
Another interesting problem that can be solved with indicator random variables is the
well known birthday paradox problem. The problem is - "How many people do you
need in a room to have at least 2 with the same birthday?" (We assume that
Step 1: Characterize optimality
Without loss of generality, we will assume that the a's are sorted in non-decreasing
order of finishing times, i.e. f1 f2 . fn.
Define the set Sij
Sij = cfw_ak S : fi sk < fk sj
as the subset of activities that can occur be
Hiring Problem
Consider that you are in charge of hiring and are looking to fill an office position. The
prospective candidates are sent by an employment agency and are assumed to be
numbered 1.n. Your hiring strategy is to interview each candidate and hi
Let us first formalize the problem by assuming that a piece of length i has price pi. If
the optimal solution cuts the rod into k pieces of lengths i1, i2, . , ik, such
that n = i1 + i2 + . + ik, then the revenue for a rod of length n is
Therefore the opt
Construction
1. Select a prime number p such that for every key k (clearly p > m)
0 k p-1
2. Randomly select a constant a such that
1 a p-1
3. Randomly select a constant b such that
0 b p-1
4. Construct the hashing function as
Using this procedure it can
Longest Common Subsequence
Given two sequences X of length m and Y of length n as
X = <x1, x2, ., xm>
Y = <y1, y2, ., yn>
find the longest common subsequence (LCS).
Step 1: Characterize optimality
The brute force procedure would involve enumerating all 2
Indicator Random Variables
The technique of indicator random variables is based upon the concept of
an event either occuring or not occuring. Thus for an event A (which is a random
event), we will define an indicator variable as
Thus I simply indicates wh