Part II - WordPress.com

Section 4.6: #33 33. The sieve of Eratosthenes, named after its inventor, theGreek scholar Eratosthenes (276–194 B.C.E.), provides a way to find all prime numbers less than or equal to some fixed number n. To construct it, write out all the integers from 2 to n. Cross out all multiples of 2 except 2 itself, then all multiples of 3 except 3 itself, then all multiples of 5 except 5 itself, and so forth. Continue crossing out the multiples of each successive prime number up to √n. The numbers that are not crossed out are all the prime numbers from 2 to n. Here is a sieve of Eratosthenes that includes the numbers from 2 to 27. The multiples of 2 are crossed out with a , the multiples of 3 with a \, and the multiples of 5 with a —. Use the sieve of Eratosthenes to find all prime numbers less than 100. So, n=100 and √n=10. Prime numbers from 2 to n(10) are 2,3,5,7. Thus, we need to cross out all the numbers from 1 to 99 that are the multiples of those four prime numbers. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Therefore, Prime numbers less than 100 are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97. Section 9.3: #29 Summary To solve this problem, you first need to know how to convert binary numbers to decimal numbers and you need to use The Difference Rule which can be find on page 541 of the textbook. 29. Refer to Example 9.3.5. a. Write the following IP address in dotted decimal form: 11001010 00111000 01101011 11101110 = 202.56.107.238 So we need to convert each string of 8­ bits binary number to decimal number: 11001010 = 2⁷ + 2⁶ + 2³ + 2¹ = 202 00111000 = 25+24+23=56 01101011 = 2⁶+25+23+2¹+20= 107 11101110 = 2⁷ + 2⁶+25+23+22+2¹=238 b. How many Class A networks can there be? For Class A, first number must zero. So there are 7 spots left for Network ID and each spot can be 2 choices (either 0 or 1). So all possible IDs are 2⁷ which is 128. However, Network ID can’t be 00000000 or 01111111. Therefore, possible IDs for Class A are 128­2=126. c. What is the dotted decimal form of the IP address for a computer in a class A network? The network IDs for a Class A network go from 00000001 (= 1) through 01111110 (= 126). In addition, the last 24 bits can be any integer from 0 (= 00000000) through 255 (= 11111111), except that they cannot all be 0 or 255 simultaneously. d. How many hosts IDs can there be for a Class A network? There are 24 positions and each positions can be 2 choices(0 or 1). There can be 224 = 16,777,216 possible host IDs. However, since they cannot all be 0 or 255 simultaneously, two possible choices are taken out. Therefore, there are 16,777,214 possible host IDs in a Class A network. e. How many Class C networks can there be? For class A, the first three numbers must be 110. So there are 21 spots left for Network ID and each spot can be 2 choices (either 0 or 1). So all possible IDs are 221=2,097,152. f. What is the dotted decimal form of the IP address for a computer in a class C network? The network IDs for a Class C network go from 00000000(= 0) through 11111111 (= 225). In addition, the last 21 bits can be either 0 or 1. g. How many hosts IDs can there be for a Class C network? The Hosts ID for Class C networks are 8­bits in length and one bit can be either 0 or 1. Thus, there are 28 = 256 possible IDs. h. How can you tell, by looking at the first of the four numbers in the dotted decimal form of an IP address, what kind of network address is from? Explain. Since the network address for Class A starts with a 0, the last three numbers must be 0­000,0­011,0­001,0­100, 0­111,0­110,0­101,0­010. On the other hand, the network address for Class B starts with a 10, the remaining two numbers must be 10­00,10­01,10­11,10­10. While the network address for Class C starts with a 110, the last remaining number must be 110­1,110­1. i. An IP address is 140.192.32.136. What class of network does it come from? 140 = 128 + 8 + 4 = 10001100, which begins with 10. Thus the IP address comes from a Class B network. j. An IP address is 202.56.107.238. What class of network does it come from? 202=128 + 64 + 8 + 2=11001010 which begins with a 110. Thus, the IP address comes from a Class C network. Section 9.6: #18 Summary To solve this problem, you first need to know what from formula from Sections 9.2, 9.3, 9.5, and 9.6 which can be find on page 590 of the textbook. 18. A large pile of coins consists of pennies, nickels, dimes, and quarters. a. How many different collections of 30 coins can be chosen if there are at least 30 of each kind of coin? b. If the pile contains only 15 quarters but at least 30 of each other kind of coin, how many collections of 30 coins can be chosen? c. If the pile contains only 20 dimes but at least 30 of each other kind of coin, how many collections of 30 coins can be chosen? d. If the pile contains only 15 quarters and only 20 dimes but at least 30 of each other kind of coin, how many collections of 30 coins can be chosen? a. Since there are at least 30 coins of each kind of coin, there is a possibility that we can pick all 30 of the same kind. So repetition is allowed and order doesn’t matter since each kind of coin is the same. So we use the formula C(k+n­1 k). There are four types of coin (k=4), and we pick 30 coins (n=30). Thus, there are C(33 4) possible ways. b. Now that there are only 15 quarters, we would have to subtract the case where we pick 15 quarters out from our possibility. For that scenario, k still equal to 4,but n=15. Thus, there are C(33 4)­C(17 4) ways. c. Same as problem B, we would have to subtract the case where we pick 20 dimes out from our possibility. For that scenario, k still equal to 4,but n=20.Thus, there are C(33 4) ­C(20 4) possible ways. d. Now, the pile contains only 15 quarters and only 20 dimes. Thus, we need to subtract the case where we pick 20 dimes out and the case where we pick 15 quarters out. Therefore the answer is C(33 4) ­C(20 4)­C(17 4). Section 10.7: Biography of Edsger W. Dijkstra Edsger Wybe Dijkstra (11 May 1930 ­ 6 August 2002) was a Dutch computer scientist that contributed greatly to developing programming languages, and he was the Schlumberger Centennial Chair of Computer Sciences at The University of Texas at Austin from 1984 until 2000. Dijkstra was born in Rotterdam. His father was a chemist who was president of the Dutch Chemical Society, and his mother was a mathematician that never had a formal job. Dijkstra attended Leiden University majoring in theoretical physics before he realized he was more interested in the worlds of mathematics and computer science. Dijkstra was a professor at the Eindhoven University of Technology, and later he was a researcher at Burroughs Corporation. Dijkstra made many contributions to both the mathematics and computer science fields. The contribution he is most well­known for is his shortest path algorithm, known as Dijkstra’s algorithm. This algorithm was a graph search algorithm that finds the single shortest path between two vertices for a graph with non­negative edge path costs. Dijkstra’s algorithm is often used in routing and as a subroutine in other graph algorithms. Dijkstra developed his algorithm in 1956, and he later published it in 1959. He went on to develop many other algorithms including the Banker’s algorithm and the semaphore construct for coordinating multiple processors and programs. Dijkstra’s Algorithm Pages 710­714 12. Use Dijkstra’s algorithm for the airline route system of Figure 10.7.3 to find the shortest distance from Nashville to Minneapolis. Make a table similar to Table 10.7.1 to show the action of the algorithm. KEY: A = Nashville B = Louisville C = Minneapolis D = Cincinnati E = Chicago F = Milwaukee G = Detroit H = St. Louis Step > B C D E F G H 1 A 151 A 695 A ∞ ∞ ∞ ∞ ∞ 2 B 151 A 695 A 234 B 420 B 499 B 457 B 393 B 3 D 151 A 695 A 234 B 420 B 499 B 457 B 393 B 4 H 151 A 695 A 234 B 420 B 499 B 457 B 393 B 5 E 151 A 695 A 234 B 420 B 494 E 457 B 393 B Therefore, by Dijkstra’s algorithm, the shortest distance from Nashville to Minneapolis (A to C) is the direct route between them (A>C) with a total weight of 695. 14. Use Dijkstra’s algorithm to find the shortest path from a to z for each of the graphs in 13­16. In each case make tables similar to Table 10.7.1 to show the action of the algorithm. Step > b c d e f g z 1 a 1 a ∞ ∞ 4 a ∞ ∞ ∞ 2 b 1 a 2 b ∞ 4 a 8 b ∞ ∞ 3 c 1 a 2 b 3 d 4 a 8 b 10 c ∞ 4 d 1 a 2 b 3 d 4 a 8 b 10 c 23 d 5 e 1 a 2 b 3 d 4 a 5 e 10 c 23 d 6 f 1 a 2 b 3 d 4 a 5 e 6 f 23 d 7 g 1 a 2 b 3 d 4 a 5 e 6 f 7 g Therefore, by Dijkstra’s algorithm, the shortest distance a to z is the route a > e > f > g > z with a total weight
of 7. Reference: O'Connor, J J and Robertson, E F. Dijkstra Biography. The MacTutor History of Mathematics, School of Mathematics and Statistics, University of St. Andrews, Scotland. 11 October 2013. Print. S. S. Epp. Discrete Mathematics with Applications (Fourth Edition). Brooks­Cole, Boston, 2004.