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

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
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 ) ?
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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 ).
Background image of page 5

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

View Full DocumentRight Arrow Icon
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?
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
Mathematical induction / Recursion s Base case : n = 1. Left side = red;
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2010 for the course CS 1234 taught by Professor Chan during the Spring '10 term at University of the Bío-Bío.

Page1 / 46

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online