{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture_01

# lecture_01 - 0250B Algorithms(advanced class Regular class...

This preview shows pages 1–10. Sign up to view the full content.

0250 B Algorithms (advanced class) s Regular class focuses on s how basic algorithms work s applications of algorithms s Advanced class puts more emphasis on s problem solving skills 0250B / TW Lam 09 s mathematical proofs (why it works) s complexity analysis (how fast it is). s Final examination: same paper and marking standard s Assignments: more challenging and demand more original thinking.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Basic concepts Problems : input output Algorithms : a sequence of instructions that can produce the desired output from any given input. Correctness : always compute the desired output. ime complexity/efficiency 0250B / TW Lam 09 2 Time complexity/efficiency : s how many steps: a function of the input size (usually denoted by T(n), where n is the input size). s worst case (versus average case, best case) s asymptotic behavior: the trend (i.e., when the input is large); big O notation s e.g., merge sort O(n log n) time; bubble sort O(n 2 ) time.
Big Oh and Omega Let T(n) be a function of n. s T(n) = O (f(n)) There exists a constant c such that, for all sufficiently large n, T(n) c f(n). .g., if T(n) = n 2 n 1.5 300, then T(n) = O(n 2 0250B / TW Lam 09 3 E.g., if T(n) = n + n + 300, then T(n) = O(n ). Is T(n) = O(n 3 ) ? O(n 1.9 ) ? s T(n) = Ω (f(n)) There exists a constant c such that, for all sufficiently large n, T(n) c f(n). E.g., T(n) = Ω (n 2 ). Ω (n 2.3 ) ?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
n 2 = O(n) Does it make sense ? Consider the following mathematical induction. Base case: when n=1, n 2 = n = O(n). Induction step: Assume that n 2 = O(n) for any n 1. 0250B / TW Lam 09 4 Consider the case for n+1: (n+1) 2 = n 2 + 2n + 1 = O(n) + 2n + 1 = O(n). Anything wrong ? Induction hypothesis
Efficient algorithms Common sense: An algorithm is efficient if it runs quickly on real input instances. Technically, an algorithm is efficient if it has a polynomial running time. 0250B / TW Lam 09 5 To be realistic (especially for large input), we aim at a polynomial no worse than O(n 3 ).

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Polynomial time 0250B / TW Lam 09 6 • Processor speed: a million high-level instructions per second. • Very long = exceeds 10 25 years • Processors of 1000 times faster: how much would it help?
Warm-up problem: coloring Input : n distinct and un-parallel lines on a plane. Output : assign colors to the regions formed by these lines such that neighboring regions (which share at least one common edge) have different colors. R 0250B / TW Lam 09 7 Can we use only two colors? G B R B G R

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Using fewest number of colors s Are two colors always sufficient to color the regions formed by any n lines? s If yes, how to color these regions? 0250B / TW Lam 09 8
Mathematical induction / Recursion s Base case : n = 1. Left side = red;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 46

lecture_01 - 0250B Algorithms(advanced class Regular class...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online