2.6 APPLICATIONS OF INDUCTION & OTHER IDEAS IMPORTANT THEOREMS

advertisement
2.6 APPLICATIONS
OF INDUCTION & OTHER IDEAS
IMPORTANT THEOREMS
MIDWESTERN STATE UNIVERSITY – COMPUTER SCIENCE
DR. RANETTE HALVERSON
THEOREM 2.8 – BINARY SEARCH
• For any non-negative integer n, at most n+1 comparisons are
required to determine if a particular number is in a list of 2n
sorted numbers.
• Alternative: For any sorted list of n numbers, at most log2 n +
1 comparisons are required to determine if a particular
number is in the list.
• Binary Search Complexity: O (log2 n)
THEOREM 2.9 – MERGE SORTED LISTS
• Let A & B be sorted lists of numbers (both decreasing or
increasing). Assume positive integer n represents the combined
total of numbers in the 2 lists. A & B can be merged into a single
list of sorted numbers in at most n-1 comparisons.
• Merge Complexity: O(n)
THEOREM 1.3 – NUMBER OF SUBSETS
YES, FROM CHAPTER 1
• If n is any non-negative number, the a set with n elements has
exactly 2n subsets.
• Note – this can be used to determine the number of relations
on a set.
THEOREM 2.10 – SUBSETS OF N ITEMS FROM R ITEMS
• Let S be a set of n elements & r is integer 0 <= r <= n. The
number of subsets of S containing exactly r elements is
n! / ( r! (n-r)! )
• Application: How many 2 person committees can be selected
from a set of 5 people?
THEOREM 2.11 – INTEGERS & PRIMES
• Every integer greater than 1 is either prime or a product of
primes.
Homework – Section 2.6
• Pages 91-92 – Exercises 1-8, 13 – 28
• Homework – Supplementary Section
• Pages 95 – 96 – Exercises 1-8, 13-18, 31, 34, 35
Download