Presentation is loading. Please wait.

Presentation is loading. Please wait.

2.6 APPLICATIONS OF INDUCTION & OTHER IDEAS IMPORTANT THEOREMS MIDWESTERN STATE UNIVERSITY – COMPUTER SCIENCE.

Similar presentations


Presentation on theme: "2.6 APPLICATIONS OF INDUCTION & OTHER IDEAS IMPORTANT THEOREMS MIDWESTERN STATE UNIVERSITY – COMPUTER SCIENCE."— Presentation transcript:

1 2.6 APPLICATIONS OF INDUCTION & OTHER IDEAS IMPORTANT THEOREMS MIDWESTERN STATE UNIVERSITY – COMPUTER SCIENCE

2 PROVE THE FOLLOWING USING INDUCTION (1 + 2 +... + N) 2 = 1 3 + 2 3 + …+ N 3

3 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 2 n sorted numbers. Alternative: For any sorted list of n numbers, at most log 2 n + 1 comparisons are required to determine if a particular number is in the list. Binary Search Complexity: O (log 2 n)

4 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)

5 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 2 n subsets. Note – this can be used to determine the number of relations on a set.

6 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)! ) Also called combinations of n things taken r at a time. Application: How many 2 person committees can be selected from a set of 5 people?

7 PASCAL’S TRIANGLE The rth column of the nth row is C(r,n)= n! / ( r! (n-r)! ) 11 1 2 1 13 3 1 1 4 6 4 1 1 5 10 10 5 1 C(0,0) C(1,0) C(1, 1) C(2,0) C(2,1) C(2,2) and so on What about permutations of n things taken r at a time???

8 EVALUATING C(N,R) From Pascal's triangle we see that the following is true C(n,r) = C(n-1,r-1) + C(n-1,r) So how do you calculate C(n,r) in a computer program?

9 THEOREM 2.11 – INTEGERS & PRIMES Every integer greater than 1 is either prime or a product of primes. Could you write a program that printed the primes and do it efficiently? How. Could you write a program that converts an integer into its product of primes?


Download ppt "2.6 APPLICATIONS OF INDUCTION & OTHER IDEAS IMPORTANT THEOREMS MIDWESTERN STATE UNIVERSITY – COMPUTER SCIENCE."

Similar presentations


Ads by Google