{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSC_226_Midterm_6

# CSC_226_Midterm_6 - At each stage i and j are compared...

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

10. = , = , = ( - )+ ( - ) F1 1 F2 1 Fn F n 1 F n 2 n 3 P(n) : + + … + = ( + ) F12 F22 Fn2 FnF n 1 Domain : {n| n ≥ 1} Basis: P(1) : 1 = 1 ∙ 1 (True) Proof: P(n + 1) : + + … + + + F12 F22 Fn2 Fn 12 = ( + )+ ( + ) FnF n 1 F n 1 2 (Inductive Hypothesis) = + ( + + ) Fn 1 Fn Fn 1 (Factor Out ( + ) F n 1 ) = ( + ) ( + ) F n 1 F n 2 ( + + = ( Fn Fn 1 F n + ) 2 from given formula) 11. ( ) bn mod m is a binary search algorithm. Assume there are = n 2k elements and that k is a non negative integer. Assume i and j are the first and last term of the restricted list at a given stage. At each stage, i and j are compared using i < j to see if there is more
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: At each stage, i and j are compared using i < j to see if there is more than one term present. Two comparisons are used when there are 2k elements, two more when there are + 2k 1 elements, and so on until two comparisons are used when the are = 21 2 elements left. Finally when one term is left, two more comparisons are made, one to compare i and j and the other to determine if the term is x. At most there are 2k + 2 = 2*log(n)+2 comparisons which is O(log n)....
View Full Document

{[ snackBarMessage ]}