{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture3

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

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

Lecture 3 Nearest Neighbor Algorithms Shang-Hua Teng

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

View Full Document
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
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

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

View Full Document
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
How to multiply 2 n-bit numbers × ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************ ************************ operations bit Complexity bits 2 : Size Input 2 n n

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

View Full Document
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.
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

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 / 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
Ask a homework question - tutors are online