Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
25 views
Algorithms Standard
Algorithm
Uploaded by
tkarthikey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Algorithms Standard For Later
Download
Save
Save Algorithms Standard For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
25 views
Algorithms Standard
Algorithm
Uploaded by
tkarthikey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Algorithms Standard For Later
Carousel Previous
Carousel Next
Save
Save Algorithms Standard For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 38
Search
Fullscreen
Discrete mathematics Naan Models, Representation, Systems eee a erica) erent Orientation in space and time Deere ene Tee om Statement of inquiry a ce Representing complex spatial problems in graphical form enables us to “di develop efficient systems that allow us to solve them more easily k Factual fee. Fs -_ Whatare algorithms and how can they be used in different contexts? 2 leg * What are minimum spanning trees and how can they be used in solving real problems? ; Conceptual * How can weighted graphs be used co represent real-world situations and solve related problems? * What are divisibility rules? Debatable * Are algorithms always the most efficient way to solve a problem? + Do algorithms designed to find minimum paths always find the optimal paths?Peto Consider the graph below a What is the degree of each vertex? A B Dessau eee eet cee ces Conese gad RS emer Rena et cen Reena eee Deer een ens DO De set encom eran gee eed ed eee eer een ern et Neco one ea ene eTPTE olpete Muar eta Te ord Graph theory review: Graphs, Th subgraphs, and trees In) the voor ; nd the sum of the degrees of the vertices in B this graph. Can you suggest how this relates to the number a of edges? - a Ret ss ‘one Ce F Consider the given graph. ‘ a List the degrees of the vertices, | @ Fact 3 > b What do you notice about the sum of the hen we list the degrees F Gacneeere degrees, compared to the number of edges? in aseending order, we Can you explain? call thelist the degree Saeeeneant © Can you generalise your observation from A se In thisease itis pare b? yg 2.2.4,4,4,4) ¥ : Ag Solution tor a The degrees of the vertices are as follows: eae that dea(A) = deg(E) = deg(B) = deg(D) = 4, deg(C) = deg(#)=2 Brig | b The sum of the degrees is 4+444+4+242=20 The number of Asi: edges is 10, so the sum of the degrees is rwice the number of edges. i, This is because each edge is counted twice. For example, edge AB is counted both at A and B. Since an edge connects two vertices, every edge creates one degree to cach vertex. Thus, every edge creates two degrees. If the number of edges is m then the number of degrees is 2 ———— ee The types of graph that we will study in this chapter are connected and | simple. Remember that connected means that each vertex is connected (adjacent) to another. In other words, there are no vertices of degree 0Bpsinple wraphs there is no more than one edge connecting each pair vertices. je diagram below shows two graphs that are not simple aph there are two vertices with two edges between them while Dpahe frst Besccond graph contains a loop. B) IX Benember that trees are simple connected graphs, where there is only Bie way of getting from one vertex to coiee Tharetaus sean Bimected graph with a unique simple path between any pair of vertices. Thus, a tree has no cycles. wa t Betaph with cycles can be made into a tree by deleting appropriate edges Bkemove the cycles while keeping the graph connected. Because a tree will Batire all che vertices, but not all the edges, of the original graph, we can say Hat the set of elements of the tree is a subset of the set of elements of the Bikinal graph. Therefore, we call it a subgraph. Bsimple connected graph where each vertex is connected to all other vertices Béalled complete graph. Below are the first six complete graphs: PONG!edges in a complete graph equals the Can you explain why the number of binomial coefficient *C | Reiner rere Eoreeeareipa | s comple gp ected to the utilities of water (W), gas (G) ang nin - 1) electricity (E) as shown in the diagram, Ca HI HW HB Each connection will be an edge connecting a house toa utility Is it Possible to connect each of the houses to each of the iatilities ithour of the edges crossing? any: A planar graph is a graph where the edges do not cross. In Explore 20.2 you discovered that the given graph is not planay as you cannot draw the last edge without crossing any of the other ones The graph in Explore 20.2 is known as a bipartite graph, because the avo Sets of vertices are not connected amongst themselves. I is known aK. Afesinsplamstgaphis crossing. We can, however, redraw it as shown in the diagram, a region bounded by a see ats ‘ a | ofedges and vertices. The ‘outer region i considered as one face, For example, the graph below has 3 faces. 3 Khas 6 edges and 4 vertices. In its planar form it has 4 faces, as shown in the same diagram: 3 of the faces are inside the graph and th fourth is outside it fies Cree For each graph: i state the number of edges ii state the number of vertices ili state the degrees of the vertices i check that the sum of the degrees is twice the number of edgesFrom the graph shown, draw a subgraph that a isanotatree b has more vertices than edges ¢ isdisconnected d__ is complete B 4 t F D E 3. The graph shows glass fibre cables connecting houses B to F to the main source at A. a Is this graph a tree? Explain your answer b- Why is it important that the graph is connected? © Which cable (edge) could you remove for the graph to remain connected? 4 Watch the TED-Ed video on the Control Room Riddle, in which you are asked to find out on what floor of a pyramid the Control Room can be found. Try to solve it by yourself, before you watch the Each room can be represented by a vertex nd each door by an edge What isHiscalled the complement of G. For each graph, write down the number of edges, vertices and fae Fut Your results in a table in that order. Can you find a relationship between the three? Research Euler's formula and check your result, AAA 6 How many more edges are there inthe complete graph K; than inthe complete graph K. 7 Show that the graph below is bipartite, 8 Consider the graph below This graph is planar. Redraw it so that no two edges cross List the number of vertices v, edges e and faces fin the redrawn graph, € Find a relationship between v, ¢ and f found in part b. d_ Generalise the relationship in part c, 9 Suppose that in a group of five people, Alex, Bert, Cathy, Dan and Eric, the following pairs of people are acquainted with each other. + Alex and Cathy + Alex and Dan + Bert and Cathy + Cathy and Dan + Cathy and Eric Draw a graph, G, to represent this information b Ina meeting of this group, new acqua inces will result, Draw a graph, H, to represent the new acquaintances. © What is the graph of G UH?‘x A, TN Fi TAY S Sata Inthis section, we will introduce different kinds of problems related to weighted graphs. A weighted graph is a graph in which each edge has a number associated There are two famous types of problem linked to weighted graphs. In this section we are going to solve them using trial and error. In the next section We will introduce a more systematic approach to solving these problems. Inthe first type of problem, the edges represent roads or travel routes, and the numbers represent distances. We need to find the shortest travelling, distance while visiting all vertices, Cee The vertices in this diagram represent different landmarks in a city. The numbers on the edges represent travelling times between them. What would be the fastest way to travel from A to D, visiting each landmark (vertex) on the way? The second type of problem deals with minimum spanning trees. These are trees that make sure all vertices are connected, while minimising When graphs are relatively simple, we can, quite easily, find the solution Using trial and error, as shown in Worked exampl‘The diagram shows the cost, in hundreds of dollars, of connecting a number of computers to main server. Each vertex represenn ac ‘omputg and the numbers on the edges represent the costs of the ‘connecti ions, ‘What isthe minimum cost of building this network? Solution Understand the problem enced to connect all the computers to the server (which could be at any Of the vertices) at minimum cost. Make a plan We will start at A and connect i o the next computer using the cheapest connection. We will then do the same at that computer and so. on, without sreating a cycle, until we have connected all the computers, Carry out the plan Starting at A, the cheapest connection 8) is to B. Now A and B are in the network. The next cheapest connection (9) is from A to G. The next | cheapest is the edge between B and G, but since G is already in the network ‘we'll not use that, Instead we will choose the edge between A and F 12) Next are GE and GC (in any order) and finally ED, The resulting minimal spanning tree is shown in the diagram,+9412 +144 14 + 11 = 68, meaning that the Bike woral weight i Eheanest solution will cost $6800 ook back 7 vertices, any spanning tree must have 6 edges. Looking at ince we have [he tree we have, the numbers we added are mostly the smallest weights Grailable in the graph, A smaller sum can be 8 , such a graph is not a tree. For example, 8 +9 + 10 represents a Instead of randomly choosing edges, we are following an algorithm. or example, the steps of an algorithm for adding two digit numbers is: 1 Add the tens digits 2 Add the ones digits. 3 Add the numbers from steps 1 and 2. So to add 15 and 32 using that algorithm 1 Add 10 and 30 to get 44 2 Add 5 and 3 Add 40 and 7 to get Lo vision is another example of an et the answer: server could be anywhere. In real life, this is often not the case, as servers need cooling and an extremely powerful and reliable source of electricity Environmental impact is therefore also a consideration. Where would put the server, if you could choose any of the A variation on the problem outlined in Explore 2033 is the travelling sales holdi before returning home. The salesperson would likely travel the shortest an problem (TSP). The name comes from a job title. The person pharmaceutical companies send their sales representatives to different doctors, introducing them to new products to prescribe to their patients 9410411 + 12413 = 63 Howeve ipcle ABG. We also see that the graph we get is not connected By following the relatively simple plan outlined in Worked example 20.2 thm, when you follow the steps In Worked example 20.2 we made the network on the assumption that the his job would travel from town to town to sell a particular product, possible distance to visit all the towns before returning home. For example, An algorithm isa problems or ea class of step-by-step solution ctions ikea recipe.r 2 0 Py olgte Man Laatolar-La (ord There is currently no proven solution for the TSP Available solutions are approximate, and, cities are involved, i takes 2 lor of computing time to “Travelling from city A, a salesperson must travel to all cities once before returning home The distances between the cities are given by the weights of the edges, which are the only possible connections between the cities. Can you find the minimum total distance to be travelled? 4 denice 1 a Find the minimum spanning tree of the giveh graph, starting at A and using the method outlined in Worked example 20.2. 5 b Now find the minimum spanning tree, starting at vertex D. € Did you get the same result in part a and part b? Explain why that might be the case. 2. The diagrams show two street networks. The first shows Jason's walk from home (H) to school (S). The second shows Justin’s walk from home (H) to school (5). The weights of the edges represent the time taken in ‘minutes. Who can get to school the quickest? Explain your answer.Find the minimum spanning tree for the graph below. ne A E1¢ VAS Mc pS raz ‘4 What is the shortest travelling salesman trip, starting at City E and returning to the start, in this network? b_ Find the minimum spanning tree of the network Find the difference in weight between the longest and the shortest path between X and Z in the graph below, where cach vertex is visited exactly once. Find the minimum spanning tree for the graph in question S,Py gtk Marlatt arly 20.2.2 Directed graphs Remember that a directed graph is a graph in which the direction of travel from one vertex to the next is fixed. The direction of travel is indicated by arrows, as in the diagram, In a directed graph, the edges are called ares. Vertex A is called a source, as there are no arcs entering A. Vertex E is calle a sink as there are no arcs leaving it B 5 Restricting the direction of travel has an impact on how we solve the graph problems outlined in the previous section. In this section, we will look at exactly how the limitations on the direction of travel impact the problems we have looked at earlier in this chapter. | enone In the given graph, how many distinct pathways are there leading from A to G? Can you identify any sinks or sources? Beeeecmere xed from a part of the city shown below. The ery week, rubbish is coll arrows show whether streets are one-way or two-way and the numbers show street intersections. Draw a graph that will enable you to plan the tubbish collection by one truck that will attempt to avoid passing a street more than once. a = - Solution We need to make a directed graph that shows the connections between the different intersections. The intersections can be represented by vertices and the streets by edges, The vertices do not have to be at the same geographic position as in the map. The important thing is to make sure that adjacent vertices are correctly identified in our graph. Here is one such graph By trial and error, we find that the truck must pass through some streets twice, One such tour is 1-2-6-7-4-5-6-2-3- 7-41Discrete mathematics Q. Investigation 20.1 The directed graph shows the roads that Pete (P) can take to vise his frigng Suhani (5). Along the way, he may or may not visit Liam (L). s 3 ¢ | 4 F a 1. How many ways are there for Pete to get to Suhani’s house? 2 How many of these pass by Liam’s house? b 3 How many of these avoid Liam’s house? ic ——EESE— eee Cereaeuerres 41 d "or the given graph: f Benes | A é F alist the paths you can take to get from B to F bb list the paths you can take to get from A to F. 2 For the given graph B ‘ A D 5h i i a how many vertices are there b how many edges are there?¢ List the different paths from: i AtoC ii AtoD 3 Consider the given graph B E D F i Verify that it is not possible to make a circuit visiting each vertex only once What change would make this possible? Is it possible to go around each edge once and return to where you started? The diagram shows a map of a city centre. The arrows indicate the direction of traffic. A courier car is at point A and must pick up a package from B and deliver it to C, What is the best route for the car to drive? t Ce 4 , = = 5 Inthe given graph, you start at A and you can move only right and up. How many ways are there to get to B, C, D and E?The word algorithm has the century Middle Eastern mathematician Muhammad ibn Masi al Kh inised as Algoriteni algorithms to find ehe minimum spanning tree. Another famous algorithm is Kruskal whi typeof An algorithm, as we saw carlier, is a clearly defined set of instrueng when followed in order, always leads to the solution of a particulal problem, Prim’s algorithm aims to find th shortest spanning tree in a Here is a simplified form of this al Step 1: Start with any Step 2: Connect this vertex to the nearest vertex using the edge with the smallest available weight Step 3: Connect the next vertex that is nearest to any of those y connected. Step 4: Repeat until all vertices are connected. Step 5: Add the weights of all edges included. This isa minimum spanning OEE c an you apply Prim’s algorithm twice to the given aph, starting at two different vertices? Compare your two Ceres Apply Prim’s algorithm to the given weighted graph to find the minimum’ spanning tree.Solution Sep 1: We choose to start at P. Beep 2: We connect P ro O using the edge with weight 6 (the smallest possible weight) Beep 1: Next we connect Qto V (4s the smallest possible weight) Giep 1: We connect Q t0 $(5),then Sto R (2) then $ ro T (3) and finally T roU (4) Step 5: The minimum spanning tree is as shown. Its weight is 6+4e5424344=24 Ewe had started at R, Sor T, would we have got the same minimum weight? eee Find the minimum spanning tree of the following graph by inspection, starting at any point. 5 a A 4 B 3 D Find the minimum spanning tree of the graph in question 1 using Prim’s algorithm. Did you get the same result?Cy 3 Find the minimum spanning tre algorithm, 4 Find the minimum spanning tree of the following grr raph using Prim’s algorithm and starting at A 5 Yanik is an electrician. He needs to install two ceiling lights (L), ‘wo power points (P) and a light switch (LS) in a room, by connecting them all to the existing power supply (PS), The diagram shows the relevant dimensions of the room, in metres What is the minimum length of cable that Yanik must use to connect all the elements to the power supply? Ina tourist area in Central Italy, tourists with caravans can rent a Position in specified caravz A caravan site hi an sites, as positions as shown in the diagram, with distances in metres between them, Determine how these positions should be connected so that the ‘oral length of pipe to supply water required isa minimum, © of the following graph using Prim’s 20.3 Dijks vertic fo fin: Youn Intt path Youn graph you ce weigh longer The fc algori Dijkst Step 1 Step 2 Step 3 Step 4Dijkstras algorithm is de igned to find the shortest path between two give gertices of a weighted graph. This algorithm is used in mapping software fo ind the shortest route from your current location to your destination. You might have used this function on your phone (eee Inthe given graph, use any method you can think of to find the path between vertices A and E You might have found, in Explore 20.7, that there are a number of paths in this ir method, the best thing graph leading from A to E. If you do not have a bet al you can do is to try them all out and check which path has the smallest t Jatively small graph, but the more vertices it has, the weight. This is fine in a longer it will take. You will only be asked to find paths in small graphs. nodification of the original Dijkstra’s The following algorithm is a simplified algorithm. vertex. Examine all edges incident to this vertex. Step 1: Circle the starting Darken the edge with the shortest length and circle the vertex at the other endpoint. Step 2: Examine all uncircled vertices that are adjacent to the circled vertices in the graph. Step 3: Using only circled vertices and darkened edges between the vertices ertex that are circled, find the length of all paths from the starting to each vertex being examined, Choose the vertex and edge that yield the shortest path. Circle this vertex and darken this edge. (Ties are broken arbitrarily) and 3 until all vertices are circled. The darkened edges Step 4: Repeat steps of the graph form the shortest routes from the starting vertex to ‘every other vertex in the graph, including the destination vertex, + Worked example and then go back t0 more sense. Go the algorithm and the thoroughly inderstand how it works. Temay also help you to Tewill take you through the algorithmQ Worked example 20.5 Tecan be help ro Use Dijkstra’s modified algorithm to find the shortest path from A top organise your work in che oNea: a table asin Worked oN Solution To find the path, we begin by circling vertex A and examining all vertices adjacent to it We will use a table to track our steps. , namely Band G, ees moun) Renee een 1.Circle A. [B Length of path Girele C and darken AC | | | | ap i ‘| tod | B sca 3436 Adjacent | | eee |p aco | | | a E ACE - 1 GisleB | and darken | | ca | | | | Adjacent D ACBD 3+3+4=10 |toB | | > |aco—|s4aee | Adjzcene | E ACE 3+7=10 oCPath from | Length of path Exons cle D me darken cD JAdjacent 106 Adjacent oD 1, Circle and darke CE djacent toD Adjacent Jo E |5. Circle F and darken DE The shortest paths from A to all vertices are shown. Specifically we need the path to F, which is ACDF with weight 13Seer For the network in the given diagram, find the shortes What is the length (weight) of this path? | st path from 4 tog) eee rd Use Dijkstra’s algorithm to find the shortest Path ftom A to E in the graph Explore 20,7, C nur earlier | answer, Is there a difference? from mpare your answer to yor 2 3. The graph shows the pathways in a park The weights represent the time it takes to walk from one point to the next, What is the fastest way to walk from A to E? Which paths should you take? ofa =Ihe diagram shows a map of six ports and the travelling times between them in days. What is the fastest way to travel from A to G? Flow long will the journey take? Find the shortest distance from L to E 6 The diagram shows a map of part of a city. The points are road intersections and the numbers are the times it takes to cover those stretches. A courier driver is at point A. Find, using Dijkstra’s algorithm, the fastest time that this driver can take to deliver a parcel to point D. Long division and long multiplication are based will look at algorithms related to numbers. Thisis an example of Boer eee problem into a fe simpler ones. You will find Use long division to divid this technique everywhere steps of the algorithm? _— n mathematics.Peete mala tant ted There are several forms of the algorithm. You will not be required to produce this in caleulations Ieis given here for demonstration onl CMa er Use long multiplication to find the answer to 37 x 852 and identify steps of the underlying algorithm. Solution Step 1: Arrange the numbers one on top of the other and line up the peg values in columns. Step 2: Scart with the ones digit of the bottom number. Multiply it by the ‘ones digit in the top number. Write the answer below the equals line. If that answer is greater than nine, write the ones place as the answer and carry the tens digit. Step 3: Proceed right to left. Multiply the ones digit of the bottom numbeg by the next digit to the left in the top number. If youu carried a digit, add itto the result and write the answer below the equals line. If you need ta carry again, do so, Step 4: When you've multiplied the ones digit by every digit in the top number, move to the tens digit in the bottom number. Multiply as above, but this time write your answers in a new row; shifted one digit place to the left. Step 5: your last row of answer numbers. Use long addition to add your number ‘hen you finish multiplying, draw another answer line below columns from right to left, carrying as you normally do for long addition: Think about other ways to work out 37 x 852. For example, knowing that 852 = 800 + 50 + 2 can lead to another algorithm for multiplication. That is, first multiply 37 by 800, then by 50, then by 2. Finally, add the results. There can be more than one algorithm to solve a problem. However, some algorithms are more efficient than others. This means they solve the problem with the fewest number of steps or using the least amount of memory: This is particularly important when creating algorithms for computers to use, Inc alg:fit 3 6 {) Fullow the algorithm seeps b Identify the different steps of the algorithm you In questions 4-6, you nced to investigate the problem before designin 4 On the table in front of you are five cards num 20.6 to multiply 325 by Worked examp Add 3475 and 8173 without the use of a calculator. a used in part a. Subtract 3475 from 8173 without the use of a calculator Identify the different steps of the algorithm you used in p algorithm to solve it ered 1 to 5. aMalfa\2 la =i) ds from smallest co largest, starting at the left, You need to sort the card n and check that it works. using a simple algorithm. Design an algorithm ads below. The hnrce frogs and three newts on the seven lily pa 0 go to the left. Frogs le There are frogs want to go to the right and the newts want and newts can only slide one lily pad to the side or jump over a sing] frog or newt. Design an algorithm that allows both the frogs and the newts to move to their desired side. Gus & p FF TThe towers of Hanoi are a famous game in which you are asked to move a set of rings from the peg on the left to the peg on the right, in the same order as they started You can move the rings to any peg. you like, but only one at a time and you cannot put a ach ring should be on a pe J an algorithm to do this? bigger ring onto a smaller ring. E except the one moving, Can you find ‘You can use moves such as COMPARE, KEEP. and SWAP, Whe SWAR, ompare the swapped card Stare with chee 1 should pur the smallest one first. Test your algor by using Geogebeey gar Luana) Fact The absolute value is also called the modulus, 20.4.2 Absolute value and the division algorithm loping algorithms to solve common problems saves having to solve the same problem over and over again. It is like having the formula for the circumference of a circle and applying it, eather than starting from scratch and developing it all over again. In this section we are going to look at two algorithms. The first is the absolute value algorithm and the second is the algorithm for division The absolute value algorithm Remember that the absolute value algorithm is defined as follows: ceatinieee Wa ifa
0, when we divide a by b ote where q is the quotient and ris the remainder. When Youm exam divisic aa ba a Soh mt v c v b bi 1When simplified, chis gives us the division algorithm, Hou may have to ger used to the language here, but when you have read the Igample, you will sce chat this i really what you have been doing with long Mlvision all these years. i] ote cco el caeAeee For cach of the following, find the quotient and remainder when a is divi fyb and write the division algorithm in the form a= bq + r where 0 a 2=113,b=4 b a= 110,b=3 e 0 =208,b=4 Solution 4 Using long division we find that q = 28 and r= 1, so we can write .,or equivalently, 113 = 4 * 28 +1 We could also have done this calculation with a calculator 6 113: We sex 28. To find r, 28.2 we multiply the decimal part by 4:0.25x4=1 har b 110+ 3=36, remainder 2 rh That is, 110 =3 x 36 +2 enue duct of the numbers divisible by 2? Is the product divisible by 3? What about 6? 2. Take any three other consecutive integers and answer the same questions. 3 Let be an integer. What are the two consecutive integers that follow n? egers. Work out the value of this 41 product for any three values of 1 P be the product of these th Can you state a general property of P that you discovered through this, investigation? anique integers p and q such that = bq + rwhere 0 =r where ais the dividend, b 1 the quotienCred Solve the following equations for x. a |x|=3 a W neo 35 b if 3. For each of the following, find the quotient and remainder when a is m divided by b. 8. GES BES, Thus G b a=89,b=7 This is © a=183,b=13 number approa 4 For the number pairs in question 3, rewrite your answers as a = bg +r The Eu 5A number divided by 7 gives 13 with a remainder of 2. What is the as number? This is b= ng, 6 Is it true that when you divide two numbers, che divisor should always Therefe be smaller than the quotient? Justify your response. a- bis 7 Claim: All integers are either multiples of 3 or leave a remainder of 1 or 2 when divided by 3. Is the claim true? Justify your response. 8 Using the result of question 8, or otherwise, show that for a positive integer p one of the following will be divisible by 3: ppr2p+4Cara Fis. divisor of 21, since 21 =3 x Fis also a divisor of 35, since 35 = 5 x 7 S07 is a common divisor of 21 and 35. In fact, GCD(21, 35) = fa What can you say about 7 and 35 ‘plus or minus’ 21? Or 7 and 6 ‘times 35 ‘plus or minus’ 5 ‘times’ 21? b If gis a common divisor of a and b, what can you say about g and ny integers mand 1? mx atnxbfo Remember that 36 = 4 x 9 = 2? x 32, and 24=8x3= Thus GCD(36, This is one way of finding the GCD of two integers. However, when the it can take a long time to find the prime factors. Anothe approach is to use the Euclidean algorithm, The Euclidean algorithm is based on the observation that if integers # and b are divisible by g, then a ~ b is also divisible by g. This is so because if a and b are divisible by g, then we and b Therefore, it follows that id mare in gs which shows is also a multiple of g. War a Verify that 408, 1320 and 13 b Using the observation above, find the GCD of 408 and 1320 Solution a 408 = 34 x 12, 1324 1320-4 110-34) x 12 = 76 x 12 110 x 12-34 1 We use the observation outlined above. Let g be the GCD of 1320 and 408. We can subtract 408 from 1320: 1320 ~ 408 = 912 So g is a divisor of 912. Also, g will divide 912 ~ 408 = 504 as well as 504 — 408 = 96 This is equivalent to saying that g divides 1320 - 3(408) = 96 We can now repeat the operation with 408 and 96: 408 Remember that 2,3, 4, 6 and 12 are common livisors (factors) of 24 and 36. We call 12 the greatest common divisor (GCD) or highest common factor (HCF) ofDamar laterite And again, with 96 and 24: 96 - 4(24) = 0 This is where we stop, as this means that 24 divides 96 and 408, However, since 96 = 4 x 24 and 408 7 24, then it turns out that is the greatest common divisor of 96 and 408, Thus, by backtracking it is also the GCD of 408 and of 1320, Looking back at our calculation, we observe that 1320 = 55 x 24 and 408 and 1 7 x24. That is, since there is no common divisor be » 24 will be the GCD, tween 55) We can check this on a calculator: By comparison, using the prime factors of 1320 and 408 we have: 408 = 23 x 3x17 [eco(408, 1320) 1320 = 24 Px 3x5 x11 The prime factors they have in common are 23 x 3 = 24 So, GCD (408, 1320) = 24 eee he Euclidean algorithm can a so be illustrated using GeoGebra. Use the Tink below to investigace what this might look like. Can you illustrate the example above in this way? Euclidean algorithm CE The basic idea is to repeatedly use the fact that C fect eT In the previous section, you saw that a = D(a,b) = GCD|b,a~ 4)=d qb + r with some integer g, so, consider a and b as if d divides both a and b, it must divide both a and qb and, thereby, their difference r= a ~ qb. Similarly, if d divides both b and r, it should divide st common divisors of a and b and of b and r coincide 3CD(b,7). But the pair (b, well. Thus, the greate: (a,b) the pair (a, 6), onsists of smaller numbers than +0 we have reduced our task to a simple tone. And we can do this reduction again and ag; ain until the smaller number becomes 0. For exan algorith: ge Now we “ZzForexample, suppose we wish to find GCD(84, 36). Using the division algorithm we find: a2 x 36+ 12 Now we divide the quotient by the remainder to get 36= 3 x 12. Here the remainder is zero. he greatest common divisor is the last non-zero remainder. In this case itis 12. ©, GCD(84, 36) = 12 Often this division process needs to be repeated to get a remainder of zero. Weer Find: a GCD(210, 336) b GCD(S1, 109). Solution a 336= 1(210) + 126 210 = 1(126) + 84 126 = 1(84) + 42 2(42) + 0; Thus, since 42 is the last non-zero remainder, then: GCD(210, 336) = 42 2{S1) +7 Since 1 is the last non-zero remainder, GCD (51, 109) = 1 Note that in this case the last step was unnecessary. Also, numbers like 51 and 109 with a GCD of 1, are said to be relatively prime.Praga Maer Teor lowing number pairs by listing their factors first ii finding the prime factors of each i iii_using the Euclidean algorithm, a 32and 56 i b 35 and 98 © 70and 105 2. Find the GCD of 182 and using your preferred method. 3. Find the GCD of 425 and 1071 using the Euclidean algorithm. 4 GCD(12, 18) = 6 and 18 ~ 12 = 6, Can you find another pair of ‘numbers where the GCD is equal to the difference between the two? \ 5 Doyouag 348 can be expressed as a linear combination of the wo numbers. [. cee combination of both numbers. in the Euclidean algorithm that the sum of two numbers has the same GCD as those two numb ? Explain your answer. 7 A florist has 124 roses and 279 carnations. She wants to create as oer many similar flower bouquets as possible while using all of the flowers she has. a What is the biggest number of similar flower bouquets she could i b How many roses and how many carnations does each bouquet | contain? ESE oe ea) on£ [understand the definition of vertex, edge and Ican find the minimum spanning tree by applying gree of a vertex. Prim’s algorithm for weighted graphs understand what a subgraph and a tree are I can find the shortest path by applying Dijkstra’s algorithm for weighted graphs. [know the number of edges a tree with n vertices Ss ae has Tunderstand how the divisibility algorithm works. I know what a complete graph is and how to find REeaETTEEENECD of rola berrsignifies the number of its edges it contains. Tean find the GCD of two numbers by using Euclid’s algorithm OMe AC al els Re eur 1 Anew kitchen has a rectangular floor that measures 300cm x 195cm Tunderstand what an algorithm is. Before installing furniture it has to be covered with tiles, What is the size of the largest square tile that can be used to cover the floor exactly? How many such tiles will be needed? Make a sketch of K;, the complete graph with 5 vertices. How many edges are leaving from each of the vertices? Use your answer to part b to state the total number of edges in Ky Does this method also work to find the total number of edges in K,? Explain your answer3 6 Use Prim’s algorithm to find the minimum spanning tree and state fg total weight. Use Dijkstra’s algorithm to find the shortest distance from A to | Find the GCD of 384 and 1080 using: a Euclid’s algorithm, b factor trees, Look at this graph, which represents a network of paths in a park connecting six sculptures. The lengths are given to the nearest 5 m. 4 Find the minimum spanning tree and find its total weight b The city wants to signpost a tour visiting each sculpture, starting from and returning to A. Which route would you advise the city to usc? Explain your answer. © If you could build an additional path to improve on the tour, which path would you build? Explain your answerF The map shows a network of train routes connecting some cities, The weight on each edge represents the duration of travel on that route in hours. A group of travellers wants to visit each city at least once and then return to their starting point at M. a Which route would you recommend for the group? b Which, if any, routes would they have to travel more than once? € What would be the total time for the whole tour? wBen 7 wars N Eodapest \Hurgary121 b Alex: median is 30.5, LQ is 19.5 UQ is 38, IQR is 18.5 (estimates from the graph) Raul: median is 25, LQ is 16, UQ is 32, IQR is 16 (estimates from the graph) ¢ Below 32cm there are approximately 125 plants. Above 12cm there are approximately 216 ~ 33 = 183 plants, 12a Hirer Et o 2» 4% 50 heights Alex’s planes appear to be slightly taller than Raul’s plants as the median and quartile values are greater. The spread of the height b values appears to be similar for both sets of plant. © Wa.» 100 50 0 2 S07 100 1s * emperature (F) d ‘The line of best fit is: C = 1.044137 ~ 43.52 where T is the temperature (F) and C is the number of cricket chirps b As the temperature increases the number of chieps per minute also increases. © This is an example of correlation and causation. It is a strong positive correlation because the scatter graph shows the data points lie close to the trend line. Researching the possible relationship between the ewo data values identifies 1a b this as a causation. The temperature outside directly affects the rate of chemical processes within the cricket that cause the EEE chirping. A higher temperature means the process can happen at a greater rate and hence more chirps. 20 40 60 80 100 * weight (g) Line of best fit: L = 0.03281 + 2.99, where Lis the length of the spring and w is the weight added. As the weight added increases the amount of stretch of the spring increases. This is an example of correlation and causation. Itis a strong positive correlation because the scatter graph shows the data points lie close to the trend line. Researching identifies the established principle of Hooke’s Laws, therefore this is also a causation. The original length is when w = 0, 99cm. therefore L = 2 No. A weight of 1 kg is out of the range of values used to determine the line of best fit. When a value of 1000 g is substituted into the line of best fit it generates a length of 35.79 cm, this is not a reasonable stretch for a spring with initial length of 2.9m. Chapter 20 answers Do you recall? 3 A-complete graph, is a simple, connected graph, in which every vertex is connected to all other vertices2 True 5. Assubgraph is made out of a subset of the vertices and edges of the original graph. ie a il -7 ii iii q iv 14=2%7 bis 7 ii 3,2,2,2,2,3,2 iv 2 a subgeaph with a cycle b any tree, for instance with at least 1 disconnected vertex d 3 ZN 3 a No,there is a cycle ABC Also there are e only needs 6 edges for 6 vertices, but a tr 5 edges (6 - 1) b-_Ienceds to be connected, else the signal cannot reach the house (vertex). © Ledge can be removed: AB, BC, AF or CF. 6 u 7 The vertices can be subdivided into odd {1, 3,5, 7,9} and even {2, 4, 6, 8}. There are no edges connecting the vertices of either set. Note that the geaph is not complete. 8 a subgraph with a cycle B © 6+7-11=2 d v+f-e=2or equivalent: Euler's Formula for planar graphs. 9 ab ay B i, D D © K,the complete graph with 5 vertices. b,c Same result, which makes complete sense, as we are choosing the same edges, but in a different order. 2 Jason: 9 mins; Justin: 12 mins. 3 2e3eid2+ Total weight: 3 +3 + Alternative solution: FZ instead of BF. 4 a E+A+C>BDE: 841043474 32 b EB,BC,ED,EA:2+3+44+8
You might also like
Elective 4 The Mathematics of Graphs
PDF
100% (2)
Elective 4 The Mathematics of Graphs
108 pages
Chapter five elements of graph theory
PDF
No ratings yet
Chapter five elements of graph theory
27 pages
Week 1 Edit
PDF
No ratings yet
Week 1 Edit
163 pages
Introduction To Graphs (Part-I)
PDF
No ratings yet
Introduction To Graphs (Part-I)
42 pages
Elementary Graph Theory: Robin Truax March 2020
PDF
No ratings yet
Elementary Graph Theory: Robin Truax March 2020
15 pages
Lecture 09-Graph-Part 1
PDF
No ratings yet
Lecture 09-Graph-Part 1
53 pages
DS Unit 5
PDF
No ratings yet
DS Unit 5
144 pages
Chapter 10
PDF
No ratings yet
Chapter 10
49 pages
Lec (Graph1)
PDF
No ratings yet
Lec (Graph1)
87 pages
Graph Theory 1-11
PDF
No ratings yet
Graph Theory 1-11
76 pages
Graphs_and_Relations_ann
PDF
No ratings yet
Graphs_and_Relations_ann
62 pages
T3 Graph and Tree
PDF
No ratings yet
T3 Graph and Tree
70 pages
Final Maths Proj 1.4.24
PDF
No ratings yet
Final Maths Proj 1.4.24
49 pages
ppt3 Network Theory
PDF
No ratings yet
ppt3 Network Theory
66 pages
Graph Theory: Eric Shen Friday, August 28, 2020
PDF
No ratings yet
Graph Theory: Eric Shen Friday, August 28, 2020
31 pages
Graph Theory
PDF
No ratings yet
Graph Theory
8 pages
Graphs 10
PDF
No ratings yet
Graphs 10
38 pages
Lecture 2 - Graph Basics - I
PDF
No ratings yet
Lecture 2 - Graph Basics - I
31 pages
Graph_theory
PDF
No ratings yet
Graph_theory
12 pages
Acfrogcshw8 8wprjj8 Yy0ecnijmgprlytf8 Qj0pwilndau Rw6z7lbdblc3knc7f W9qzhhble2gnowchzqcatdnnt73tnjfk1k5nbl8 Ssl0dftmnth0nusgphlyrsjuknia7yrmfp Gdi3x
PDF
No ratings yet
Acfrogcshw8 8wprjj8 Yy0ecnijmgprlytf8 Qj0pwilndau Rw6z7lbdblc3knc7f W9qzhhble2gnowchzqcatdnnt73tnjfk1k5nbl8 Ssl0dftmnth0nusgphlyrsjuknia7yrmfp Gdi3x
11 pages
Lecture On Graph Theory 1
PDF
No ratings yet
Lecture On Graph Theory 1
31 pages
Random Topics in Graph Theory
PDF
No ratings yet
Random Topics in Graph Theory
43 pages
Graph Theory Piyushwairale
PDF
No ratings yet
Graph Theory Piyushwairale
21 pages
CSCE 3110 Data Structures & Algorithm Analysis: Rada Mihalcea Graphs (I) Reading: Chap.9, Weiss
PDF
No ratings yet
CSCE 3110 Data Structures & Algorithm Analysis: Rada Mihalcea Graphs (I) Reading: Chap.9, Weiss
34 pages
Graph Theory Soln PDF
PDF
No ratings yet
Graph Theory Soln PDF
10 pages
Table of Content
PDF
No ratings yet
Table of Content
20 pages
Graph Theory & Its Formal Aspects: Lecture 3-4
PDF
No ratings yet
Graph Theory & Its Formal Aspects: Lecture 3-4
42 pages
DM UNIT4 Notes
PDF
No ratings yet
DM UNIT4 Notes
8 pages
Chapter 4 Applications of Graph Theory
PDF
No ratings yet
Chapter 4 Applications of Graph Theory
71 pages
Week11 2graph011
PDF
No ratings yet
Week11 2graph011
25 pages
Discrete Math 6
PDF
No ratings yet
Discrete Math 6
47 pages
Contemporary Mathematics Revised Edition
PDF
No ratings yet
Contemporary Mathematics Revised Edition
272 pages
APPLICATION HL Oxford CH 15
PDF
No ratings yet
APPLICATION HL Oxford CH 15
23 pages
Topic 6
PDF
No ratings yet
Topic 6
92 pages
DFS - BFS (Graphs) Luis Alberto Vásquez Vargas - : Peluchin
PDF
No ratings yet
DFS - BFS (Graphs) Luis Alberto Vásquez Vargas - : Peluchin
23 pages
Elements of Graph Theory _ Mathematics for the Liberal Arts Corequisite
PDF
No ratings yet
Elements of Graph Theory _ Mathematics for the Liberal Arts Corequisite
15 pages
Module 6 Graph Theory
PDF
No ratings yet
Module 6 Graph Theory
37 pages
AAGT
PDF
No ratings yet
AAGT
109 pages
EContent 11 2023 01 30 08 32 46 UNIT4GRAPHANDTREEpdf 2022 12 27 10 42 44
PDF
No ratings yet
EContent 11 2023 01 30 08 32 46 UNIT4GRAPHANDTREEpdf 2022 12 27 10 42 44
31 pages
Lecture 5: Graphs: IIT Kanpur
PDF
No ratings yet
Lecture 5: Graphs: IIT Kanpur
7 pages
Graphs Lecture Notes
PDF
No ratings yet
Graphs Lecture Notes
22 pages
DSA
PDF
No ratings yet
DSA
10 pages
Graph Theory Notes
PDF
No ratings yet
Graph Theory Notes
84 pages
Graphs and Networks: Vertices, Edges
PDF
No ratings yet
Graphs and Networks: Vertices, Edges
15 pages
Graph Theory App To Economics
PDF
No ratings yet
Graph Theory App To Economics
47 pages
Graph Theory Reading
PDF
No ratings yet
Graph Theory Reading
14 pages
Ppt-Unit 5 - 18mab302t-Graph Theory
PDF
No ratings yet
Ppt-Unit 5 - 18mab302t-Graph Theory
72 pages
DM (Vertex, Degree, Graphs
PDF
No ratings yet
DM (Vertex, Degree, Graphs
26 pages
Unit - V &VI Graph Theory
PDF
No ratings yet
Unit - V &VI Graph Theory
55 pages
UNIT-4 (Graph)
PDF
No ratings yet
UNIT-4 (Graph)
15 pages
Graph Theory Cambridge U
PDF
No ratings yet
Graph Theory Cambridge U
75 pages
Decision Maths 1 chapter 2 Graphs and networks (including A2 content Planarity Alg) copy
PDF
No ratings yet
Decision Maths 1 chapter 2 Graphs and networks (including A2 content Planarity Alg) copy
36 pages
Graph Theory Lecture-1 by Amit
PDF
No ratings yet
Graph Theory Lecture-1 by Amit
36 pages
Introduction To Graph Theory: Department of Mathematics College of Science Al Mustansiryiah University 2023-2024
PDF
No ratings yet
Introduction To Graph Theory: Department of Mathematics College of Science Al Mustansiryiah University 2023-2024
31 pages
Chapter 1 (1)
PDF
No ratings yet
Chapter 1 (1)
84 pages
UNIT 6 Tree and Graphs
PDF
No ratings yet
UNIT 6 Tree and Graphs
30 pages
Graph Theory QB
PDF
100% (1)
Graph Theory QB
22 pages
Graph Theory 1-11 PDF
PDF
No ratings yet
Graph Theory 1-11 PDF
13 pages