Data Str & Algorithm HW Solutions 19

Data Str & Algorithm HW Solutions 19 - 19 3.11 (a)...

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

View Full Document Right Arrow Icon
19 3.11 (a) n != n × ( n 1) ×···× n 2 × ( n 2 1) ×···× 2 × 1 n 2 × n 2 ×···× n 2 × 1 ×···× 1 × 1 =( n 2 ) n/ 2 Therefore lg n ! lg µ n 2 n 2 1 2 ( n lg n n ) . (b) This part is easy, since clearly 1 · 2 · 3 ··· n<n · n · n ··· n, so n ! <n n yielding log n ! <n log n . 3.12 Clearly this recurrence is in O (log n n ) since the recurrance can only be expanded log n times with each time being n or less. However, since this series drops so quickly, it might be reasonable to guess that the closed form solution is O ( n ) . We can prove this to be correct quite easily with an induction proof. We need to show that T ( n ) c n for a suitable constant c . Pick c =4 . Base case : T (1) 4 . Induction Hypothesis : T ( n ) 4 n . Induction Step : T (2 n )= T ( n )+ 2 n 4 n + 2 n =2 2 2 n =(2 2+1) 2 n 4 2
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.

Ask a homework question - tutors are online