Discrete Mathematics with Graph Theory (3rd Edition) 231

Discrete Mathematics with Graph Theory (3rd Edition) 231 -...

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

View Full Document Right Arrow Icon
Section 8.3 229 Since 5 = n #- 1, we set m = l~J = 2. Since 7 = x > a2 = 5 we replace n by n - m = 3 and change the list to 7,10,12. Since 3 = n #- 1, we set m = r~l = 1. Since 7 = x :::; al = 7, we replace n by m = 1 and change the list to 7. Since n = 1 and x = aI, we output "true" and stop. This search required four comparisons of x with an element in the list; a linear search would have required three. (b) Since n = 11 #- 1, we set m = l121 J = 5. Since 30 = x > a5 = 12, we replace n with n-m = 6 and change the list to 15,17,22,24,30,31. Since 6 = n #- 1, we set m = l*J = 3. Since 30 = x> a3 = 22 we replace n by n - m = 3 and change the list to 24,30,31. Since 3 = n #- 1, we set m = r~l = 1. Since 30 = x > al = 24, we replace n by n - m = 2 and change the list to 30, 31. Since 2 = n #- 1, we set m = r~l = 1. Since 30 = x :::; al = 30, we replace n by m = 1 and change the list to 30. Since
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 11/08/2010 for the course MATH discrete m taught by Professor Any during the Summer '10 term at FSU.

Ask a homework question - tutors are online