Master Theorem - Introduction to Algorithms and Data Structures - Lecture Sli, Lecture notes of Computer Science

These are the Lecture Slides of Introduction to Algorithms and Data Structures which includes Horizontal and Vertical, Solution, Output, Input, Importance Values, Column Indices, Corresponding Pixels, Importance Vertical Seam, Importance Image etc. Key important points are: Master Theorem, Mergesort, Quicksort, Selection, Testing a Queue, Exception If Empty, Empty, Monotonically Increasing, Number, Problems

Typology: Lecture notes

2012/2013

Uploaded on 03/23/2013

dhruv
dhruv 🇮🇳

4.3

(12)

194 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Master Theorem, Mergesort,
Selection, Quicksort
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Master Theorem - Introduction to Algorithms and Data Structures - Lecture Sli and more Lecture notes Computer Science in PDF only on Docsity!

Master Theorem, Mergesort,

Selection, Quicksort

Testing a Queue

Q.enqueue(n)

n=Q.dequeue() # exception if empty Q.size()

Q.isEmpty()

Testing a Queue

Q.enqueue(n)

n=Q.dequeue() # exception if empty Q.size()

Q.isEmpty()

Master Theorem

Let T(n) be a monotonically increasing function that satisfies: T(n) = aT(n/b) + Θ(n d^ ) Where a≥1, b>1, d≥0.

T(n) is Θ(n d^ ) if a < bd T(n) is Θ(n d^ log n) if a = bd T(n) is Θ(n log a b^ ) if a > bd

a is number of sub- problems 1/b is size of sub- problems nd^ is cost within a given level

Analysis of min(unsorted list[n])

A. O(1)

B. O(log n)

C. O(sqrt(n))

D. O(n)

E. O(n log n)

Analysis of max(unsorted list[n])

A. O(1)

B. O(log n)

C. O(sqrt(n))

D. O(n)

E. O(n log n)

Selection(k, list)

 Returns k th^ smallest element in list

 Divide and conquer

Selection(k, list)

 Returns k th^ smallest element in list

 Divide and conquer

 Pick pivot, v

 Create three sub-lists

 Find which sub-list k is in from sub-list sizes

 Return Selection(k (^2) , appropriate-sub-list)

Quicksort(list)

 Pick pivot, v

 Construct 3 lists, SL, SV, SR

 Quicksort(SL)

 Quicksort(SR)

 Return(SL,SV,SR) append now-sorted lists

Genetic Algorithms (GAs)

 Search and optimization heuristic

 Mimics natural evolution  Genome for candidate solutions  Mutation, selection, inheritance, and crossover

 http://www.youtube.com/watch?v=JBgG_VSP 7f8 (example of Karl Sims)

 http://vimeo.com/ 12058493 (tribute)