{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture3

lecture3 - Lecture 3 Nearest Neighbor Algorithms Shang-Hua...

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

View Full Document Right Arrow Icon
Lecture 3 Nearest Neighbor Algorithms Shang-Hua Teng
Background image of page 1

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

View Full Document Right Arrow Icon
What is Algorithm? A computable set of steps to achieve a desired result from a given input Example: Input: An array A of n numbers Desired result Pseudo-code of Algorithm SUM n a a a 2 1 = n k k a 1
Background image of page 2
Pseudo-code of Algorithm SUM [ ] ( 29 s a s s n k a s a a a A k n return to 2 for SUM Algorithm 1 2 1 + = = = Complexity: Input Size n Number of steps: n-1 additions
Background image of page 3

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

View Full Document Right Arrow Icon
Example 2: Integer Multiplication c = a b When do we need to multiply two very large numbers? In Cryptography and Network Security message as numbers encryption and decryption need to multiply numbers
Background image of page 4
How to multiply 2 n-bit numbers × ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************************ operations bit Complexity bits 2 : Size Input 2 n n
Background image of page 5

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

View Full Document Right Arrow Icon
Asymptotic Notation of Complexity As input size grow, how fast the running time grow. – T 1 ( n ) = 100 n – T 2 ( n ) = n 2 Which algorithms is better? • When n < 100 is small then T 2 is smaller • As n becomes larger, T 2 grows much faster To solve ambitious, large-scale problem, algorithm1 is preferred.
Background image of page 6
Asymptotic Notation (Removing the constant factor) The Θ Notation Θ (g(n)) = { f(n): there exist positive c 1 and c 2 and n 0 such that for all n > n 0 } For example T( n ) = 4n log n + n = Θ ( n log n ) ) ( ) ( ) ( 0 2 1 n g c n f n g c
Background image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 26

lecture3 - Lecture 3 Nearest Neighbor Algorithms Shang-Hua...

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

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