Download Ming Li Talk about Bioinformatics

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Quadtree wikipedia , lookup

Array data structure wikipedia , lookup

Transcript
Lecture 6 More Divide-Conquer
and Paradigm #4 Data Structure.
 Today, we do more “divide-and-conquer”.
 And, we do Algorithm design paradigm # 4:
invent or augment a data structure.
More divide and conquer:
powering a number
 Problem: Compute an , where n is an integer.
 Naïve algorithm Θ(n).
 Divide-and-conquer:
an = an/2 an/2
= a(n-1)/2 a(n-1)/2 a
if n is even.
if n is odd
Note, another kind of divide and conquer.
Time complexity: T(n) = T(n/2) + Θ(1) = Θ(logn)
Back to Fibonacci numbers
 Recursion: not careful would give exponential
time algorithm.
 Plain linear bottom up computation: Θ(n).
 Can we do better?
n
Theorem: Fn+1 Fn
1 1
Fn Fn-1
1 0
I will prove this in class.
Then you can compute this similar to powering
of an integer in Θ(logn) steps.
VLSI tree layout
 Problem: Embed a complete binary tree with
n leaves in a grid using minimal area.
W(n)
H(n)
H(n) = Θ(lg n)
Area = Θ(n lg n)
W(n) = Θ(n)
How do we improve this embedding?
 If we wish to have an O(n) solution for the
area, perhaps we wish to have √n for L(n)
and W(n).
 What recursion scheme would get us there?
 The Master theorem Case 1 says if b=4, a=2,
then log4 2 =1/2. So if we have something like
T(n) = 2T(n/4) + o(√n)
we would get O(√n) solution for L(n) and
W(n).
H-tree embedding scheme
L(n/4)
L(n)
L(n) = 2L(n/4) + Θ(1) = Θ(√n)
Area = Θ(n)
Paradigm #4 Use a data structure.
Example 1. Heapsort
 We invent a data structure (the heap) to
support sorting.
Example 2. Subrange sum
 We want to maintain an array of integers
a[1..n], and support the following operations:


A. Increment a[i] by b; that is, set a[i] += b.
B. Subrange sum: compute the sum of the
elements a[c], a[c+1], ..., a[d].
 Augment array as follows:
a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8]
a[1..2] a[3..4] a[5..6] a[7..8]
a[1..4]
a[5..8]
a[1..8]
 Operations A and B are both in O(logn) time.