hw2-s10-rec1a-soln

hw2-s10-rec1a-soln - Problem Rec1a: We can find the order...

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: Problem Rec1a: We can find the order class of A t i = 2, At i = 3, T ( n ) = ȹ 2Tȹ ȹ + lg ȹ + lg through substitution. . ȹ n ȹ n ȹ n n n + lg n = Tȹ ȹ + lg + lg + lg n . ȹ 8 Ⱥ 4 Ⱥ 2 4 2 ȹ i −1 i −1 i −1 ȹ n ȹ ȹ n ȹ k In general, then, T ( n ) = Tȹ i ȹ + ∑ȹ lg k ȹ = T (1) + ∑ (lg n − lg 2 ) = T (1) + ∑ (lg n − k ) ȹ 2 Ⱥ k = 0 ȹ 2 Ⱥ k =0 k =0 i −1 ȹ i(i − 1) ȹ € ȹ n ȹ = Tȹ i ȹ + i lg n − ∑ k = T (1) + i lg n − ȹ ȹ . ȹ 2 Ⱥ ȹ 2 Ⱥ k =0 € ȹ n ȹ ȹ 8 Ⱥ Since our base case is T(1) = 1, we stop substituting when for i yields i = lg n. Substituting the values of i and T(1) into our expression for T(n) yields ȹ . Rearranging this and solving € ȹ lg n (lg n − 1) ȹ 1 2 2 T ( n ) = 1 + (lg n )(lg n ) − ȹ ȹ = 1 + (lg n ) − (lg n ) − lg n 2 2 ȹ Ⱥ ( ) = 1+ 1 1 2 2 (lg n) + lg n . Thus T ( n) = O (lg n ) . 2 2 ( ) € € € ...
View Full Document

This note was uploaded on 03/21/2010 for the course CS 4102 taught by Professor Horton during the Spring '10 term at UVA.

Ask a homework question - tutors are online