Docsity

An Introduction to Bioinformatics Algorithms: Randomized Algorithms and Motif Finding, Study notes of Art

Partial preview of the text

Download An Introduction to Bioinformatics Algorithms: Randomized Algorithms and Motif Finding and more Study notes Art in PDF only on Docsity!

Randomized Algorithms

and Motif Finding

Outline

  • (^) Randomized QuickSort
  • (^) Randomized Algorithms
  • (^) Greedy Profile Motif Search
  • (^) Gibbs Sampler
  • (^) Random Projections

Introduction to QuickSort

- (^) QuickSort is a simple and efficient approach

to sorting:

  • (^) Select an element m from unsorted array c

and divide the array into two subarrays:

c small

  • elements smaller than m and

c large

  • elements larger than m.
  • (^) Recursively sort the subarrays and combine

them together in sorted array c sorted

Example of QuickSort

Given an array: c = { 5, 2, 8, 4, 3, 1, 7, 6, 9 }

Step 1: Choose the first element as m

c = { 6 , 3, 2, 8, 4, 5, 1, 7, 0, 9 }

Our Selection

Example of QuickSort (cont’d)

Step 3: Recursively do the same thing to

c small

and c large

until each subarray has

only one element or is empty.

C small

= { 3 , 2, 4, 5, 1, 0

}

C large

= { 8 , 7,

9 }

m =

3

m =

{ 2 , 1, 0 } < { 4 , 5 }^8 { 7 } < { 9 }

m =

2

{ 1 , 0 } < { empty} { empty } < { 5 }

m =

4

m =

1

{ 0 } < { empty }

Example of QuickSort (cont’d)

Step 4: Combine the two arrays with m working

back out of the recursion and as we build

together the sorted array.

C small

= { 0, 1, 2, 3, 4, 5

}

C large

= { 7, 8, 9 }

{ 0, 1, 2 } 3 { 4, 5 }

{ 7 } 8 { 9 }

{ 0, 1 } 2 { empty }

{ empty } 4 { 5 }

{ 0 } 1 { empty }

The QuickSort Algorithm

QuickSort(c)

if c consists of a single element

return c

4. m ß c 1

Determine the set of elements c small

smaller than m

Determine the set of elements c large

larger than m

QuickSort(c small

)

QuickSort(c large

)

Combine c small

, m , and c large

into a single array, c sorted

return c sorted

QuickSort Analysis: Optimistic Outlook

  • Runtime is based on our selection of m :

-A good selection will split c evenly such that

| c small

| = | c large

|, then the runtime is O( n log

n ).

-For a good selection, the recurrence relation is:

T ( n ) = 2T ( n /2) + const · n

Time it takes to split the

array into 2 parts where

const is a positive constant

The time it takes to

sort two smaller

arrays of size n /

QuickSort Analysis (cont’d)

  • QuickSort seems like an ineffecient MergeSort
  • To improve QuickSort, we need to choose m to be a

good ‘splitter.’

  • It can be proven that to achieve O( n log n ) running

time, we don’t need a perfect split, just reasonably

good one. In fact, if both subarrays are at least of

size n/4 , then running time will be O( n log n ).

  • This implies that half of the choices of m make good

splitters.

A Randomized Approach

  • (^) To improve QuickSort, randomly select m.
  • (^) Since half of the elements will be good

splitters, if we choose m at random we will

get a 50% chance that m will be a good

choice.

  • (^) This approach will make sure that no matter

what input is received, the expected running

time is small.

RandomizedQuickSort Analysis

  • Worst case runtime: O( m

- (^) Expected runtime : O( m log m ).

  • (^) Expected runtime is a good measure of the

performance of randomized algorithms, often

more informative than worst case runtimes.

  • (^) RandomizedQuickSort will always return the

correct answer, which offers a way to classify

Randomized Algorithms.

Two Types of Randomized Algorithms

- (^) Las Vegas Algorithms – always produce the

correct solution (ie. RandomizedQuickSort)

- (^) Monte Carlo Algorithms – do not always

return the correct solution.

  • (^) Las Vegas Algorithms are always preferred,

but they are often hard to come by.

A New Motif Finding Approach

- Motif Finding Problem : Given a list of t

sequences each of length n , find the “best”

pattern of length l that appears in each of the

t sequences.

- Previously: we solved the Motif Finding

Problem using a Branch and Bound or a

Greedy technique.

- Now : randomly select possible locations and

find a way to greedily change those locations

until we have converged to the hidden motif.

Profiles Revisited

  • Let s =( s 1

,..., s t

) be the set of starting

positions for l- mers in our t sequences.

  • The substrings corresponding to these

starting positions will form:

  • t x l alignment matrix and
  • 4 x l profile matrix * P.

*We make a special note that the profile matrix will be defined in terms of the

frequency of letters, and not as the count of letters.