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
Give an O(n2)-time algorithm to find the longest monotonically increasing
subsequence of a sequence of n numbers.
Let SSS.S[n] be the input sequence.
Let L[i] , 1<=i <= n, be the length of the longest monotonically increas
1. For j=2 to A.length
2. Key = A[j]
3. /insert A[j] into the sorted sequence A[1.j-1].
5. while i>0 and A[i] <key
Initialization: We start b
Give a memoized version of LCS-LENGTH that runs in O(mn) time.
m <- length[X]
n <- length[Y]
for i <- 1 to m do
for j <- 1 to n do
c[i,j] <- -1
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'
A bit vector is simply an array of bits (0s and 1s). A bit vector of length m
much less space than an array of m pointers. Describe how to use a bit
to represent a dynamic set of distinct elements with no satellite data.
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
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
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
Analysis of Algorithms
Instructor: George Bebis
Appendix B4, Appendix B5.1
Definition = a set of nodes (vertices) with
edges (links) between them.
G = (V, E) - graph
V = set of vertices
E = set of edges
V = n
E = m
CS 583: Data Structures and Analysis of Algorithms: Fall 2006: D. Kaznachey
Home Work #3
1. (5 points) Suppose there is no way to represent the key -. Rewrite the BinomialHeap-Delete procedure to work correctly in this situation (see exercise 19.2-6) Ensu
Problem 1: p379 16.1-4
Not just any greedy approach to the activity-selection problem produces a maximumsize set of mutually compatible activities. Give an example to show that the approach
CS702 Current Papers Solved
1. fractional knapsak psuedo code 5marks
2. strongly connected component algo 5marks
3. prove if a|b . then a|(-b) somthing like that 5marks
5. prive 1f n is devisble by 7. n square also devisible by 7. 10marks
8. prove CLIQUE