samp1 - A LGORITHMS — S AMPLE S OLUTIONS Sample Problems...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: A LGORITHMS — S AMPLE S OLUTIONS Sample Problems I 1 Formulae you should know You should remember these properties from previous calculus classes: • log a ( b · c ) = log a ( b ) + log a ( c ) , • log a ( b/c ) = log a ( b )- log a ( c ) , • log a ( b c ) = c · log a ( b ) , • c log a ( b ) = b log a ( c ) , • 1 + x + x 2 + ··· + x n = x n +1- 1 x- 1 . 2 Sample Problems 2.1 Summation Problem 1: Let S k n be the sum 1 k + 2 k + 3 k + ··· + n k . Then 1. Calculate S 1 n and S 2 n , and 2. Show that S k n = O ( n k +1 ) . Proof: 1. We recall the formulas ( x + 1) 2 = x 2 + 2 x + 1 and ( x + 1) 3 = x 3 + 3 x 2 + 3 x + 1 . Then S 2 n = 1 2 + 2 2 + 3 2 + ··· + n 2 = 1 + (1 + 1) 2 + (2 + 1) 2 + ··· + (( n- 1) + 1) 2 = 1 + (1 2 + 2 · 1 + 1) + (2 2 + 2 · 2 + 1) + ··· + (( n- 1) 2 + 2( n- 1) + 1) = (1 2 + 2 2 + ··· + ( n- 1) 2 ) + 2(1 + 2 + ··· + ( n- 1)) + n = ( S 2 n- n 2 ) + 2( S 1 n- n ) + n = S 2 n + 2 S 1 n- n ( n + 1) . Simplifying by S 2 n , one gets S 1 n = n ( n +1) 2 . 1 Similarly, S 3 n = 1 3 + 2 3 + 3 3 + ··· + n 3 = 1 + (1 + 1) 3 + (2 + 1) 3 + ··· + (( n- 1) + 1) 3 = 1 + (1 3 + 3 · 1 2 + 3 · 1 + 1) + (2 3 + 3 · 2 2 + 3 · 2 + 1)+ ··· + (( n- 1) 3 + 3( n- 1) 2 + 3( n- 1) + 1) = (1 3 + 2 3 + ··· + ( n- 1) 3 ) + 3(1 2 + 2 2 + ··· + ( n- 1) 2 )+ +3(1 + 2 + ··· + ( n- 1)) + n = ( S 3 n- n 3 ) + 3( S 2 n- n 2 ) + 3 S 1 n- 1 + n = S 2 n + 3 S 2 n- n 3- 3 n 2 + n + 3 · n ( n- 1) 2 = S 2 n + 3 S 2 n- n (2( n 2 +3 n- 1)- 3( n- 1)) 2 = S 2 n + 3 S 2 n- n (2 n 2 +3 n +1) 2 = S 2 n + 3 S 2 n- n ( n +1)(2 n +1) 2 . Simplifying by S 3 n , one gets S 2 n = n ( n +1)(2 n +1) 6 . 2. We recall that ( n + 1) k +1 = n k +1 + ( k + 1) n k + P k- 1 ( n ) , where P k- 1 is a polynomial of degree k- 1 . Then S k +1 n = 1 k +1 + 2 k +1 + 3 k +1 + ··· + n k +1 = 1 + (1 + 1) k +1 + (2 + 1) k +1 + ··· + (( n- 1) + 1) k +1 = 1 + (1 k +1 + ( k + 1) · 1 k + P k- 1 (1)) + (2 k +1 + ( k + 1) · 2 k + P k- 1 (2))+ ··· + (( n- 1) k +1 + ( k + 1) · ( n- 1) k + P k- 1 ( n- 1)) = (1 k +1 + 2 k +1 + ··· + ( n- 1) k +1 ) + ( k + 1)(1 k + 2 k + ··· + ( n- 1) k )+ +(1 + P k- 1 (1) + P k- 1 (2) + ··· + P k- 1 ( n- 1)) = ( S k +1 n- n k +1 ) + ( k + 1)( S k n- n k ) + O ( n k ) = S k +1 n + ( k + 1) S k n- n k +1 + O ( n k ) Simplifying S k n , one gets S k n = n k +1 k +1- O ( n k ) , that is, S k n = O ( n k +1 ) . Problem 2: Calculate the sums n X k =0 k 2 k and n X k =0 k 2 2 k . Proof: Recall that n X k =0 x k = x n +1- 1 x- 1 . By differentiation, one obtains: n X k =0 kx k- 1 = ( n + 1) x n ( x- 1)- x n +1 + 1 ( x- 1) 2 = nx n +1- ( n + 1) x n + 1 ( x- 1) 2 . Multiplying by x , one gets: n X k =0 kx k = nx n +2- ( n + 1) x n +1 + x ( x- 1) 2 , ( * ) and replacing x by 2, n X k =0 k 2 k = ( n- 1)2 n +1 + 2 ....
View Full Document

This note was uploaded on 03/16/2010 for the course CSE 101 taught by Professor Staff during the Winter '08 term at UCSD.

Page1 / 10

samp1 - A LGORITHMS — S AMPLE S OLUTIONS Sample Problems...

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

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