A Level Further Mathematics for OCR A Discrete Student Book (AS/A Level) Cambridge Elevate Edition (2 Years) [Cambridge Elevate ed.] 9781108444316, 9781108445191

Written for the OCR A AS/A Level Further Mathematics specification for first teaching from 2017, this Cambridge Elevate

2,624 328 25MB

English Pages [249] Year 2017

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

A Level Further Mathematics for OCR A Discrete Student Book (AS/A Level) Cambridge Elevate Edition (2 Years) [Cambridge Elevate ed.]
 9781108444316, 9781108445191

Table of contents :
Introduction
1. Mathematical preliminaries
2. Graphs and networks
3. Algorithms
4. Network algorithms
5. Decision making in project management
6. Graphical linear programming
7. The simplex algorithm
8. Game theory.

Citation preview

Brighter Thinking

A Level Further Mathematics for OCR A Discrete Student Book (AS/A Level) Jan Dangerfield

Introduction You have probably been told that mathematics is very useful, yet it can often seem like a lot of techniques that just have to be learnt to answer examination questions. You are now getting to the point where you will start to see how some of these techniques can be applied in solving real problems. However, as well as seeing how maths can be useful we hope that anyone working through this resource will realise that it can also be incredibly frustrating, surprising and ultimately beautiful. The resource is woven around three key themes from the new curriculum. Proof Maths is valued because it trains you to think logically and communicate precisely. At a high level, maths is far less concerned about answers and more about the clear communication of ideas. It is not about being neat – although that might help! It is about creating a coherent argument that other people can easily follow but find difficult to refute. Have you ever tried looking at your own work? If you cannot follow it yourself it is unlikely anybody else will be able to understand it. In maths we communicate using a variety of means – feel free to use combinations of diagrams, words and algebra to aid your argument. And once you have attempted a proof, try presenting it to your peers. Look critically (but positively) at some other people’s attempts. It is only through having your own attempts evaluated and trying to find flaws in other proofs that you will develop sophisticated mathematical thinking. Problem solving Maths is valued because it trains you to look at situations in unusual, creative ways, to persevere and to evaluate solutions along the way. We have been heavily influenced by a great mathematician and maths educator George Pólya, who believed that students were not just born with problem-solving skills – they were developed by seeing problems being solved and reflecting on their solutions before trying similar problems. You might not realise it but good mathematicians spend most of their time being stuck. You need to spend some time on problems you can’t do, trying out different possibilities. If after a while you have not cracked it, then look at the solution and try a similar problem. Don’t be disheartened if you cannot get it immediately – in fact, the longer you spend puzzling over a problem the more you will learn from the solution. You might never need to integrate a rational function in future, but we firmly believe that the problem-solving skills you will develop by trying it can be applied to many other situations. Modelling Maths is valued because it helps us solve real-world problems. However, maths describes ideal situations and the real world is messy! Modelling is about deciding on the important features needed to describe the essence of a situation and turning that into a mathematical form, then using it to make predictions, compare to reality and possibly improve the model. In many situations the technical maths is actually the easy part – especially with modern technology. Deciding which features of reality to include or ignore and anticipating the consequences of these decisions is the hard part. Yet it is amazing how some fairly drastic assumptions – such as pretending a car is a single point or that people’s votes are independent – can result in models that are surprisingly accurate. More than anything else, this resource is about making links. Links between the different chapters, the topics covered and the aforementioned themes, links to other subjects and links to the real world. We hope that you will grow to see maths as one great complex but beautiful web of interlinking ideas. Maths is about so much more than examinations, but we hope that if you take on board these ideas (and do plenty of practise!) you will find maths examinations a much more approachable and possibly even enjoyable experience. Nevertheless, always remember that the result of what you write down in a few hours by yourself in silence under exam conditions is not the only measure you should consider when judging your mathematical ability – it is only one variable in a much more complicated mathematical model!



How to use this resource Throughout this resource you will notice particular features that are designed to aid your learning. This section provides a brief overview of these features.

In this chapter you will learn how to: work with general sequences use induction to prove results relating to sequences and series describe behaviour of sequences use the limits of sequences work with Fibonacci and Lucas numbers solve first-order recurrence relations solve second-order recurrence relations.

Learning objectives A short summary of the content that you will learn in each chapter.

Before you start… A Level Mathematics Student Book 2, Chapter 4

You should be able to use the following formulae for geometric progressions. term of a geometric progression

1 Given that a sequence has terms find: a the

term

b the sum of the first five terms. 2 Given that a sequence has terms find: a the

term

b the sum of the first

terms

c the sum to infinity Pure Core Student Book 1, Chapter 6

You should be able to use the method of induction: Check true for initial conditions, e.g. . Show true for (assuming true for

).

Hence, explain true for all positive integers.

3 Prove by induction that the sum of the first integers is

.

Before you start Points you should know from your previous learning and questions to check that you’re ready to start the chapter.

WORKED EXAMPLE

The left-hand side shows you how to set out your working. The right-hand side explains the more difficult steps and helps you understand why a particular method was chosen.

PROOF

Step-by-step walkthroughs of standard proofs and methods of proof.

Key point A summary of the most important methods, facts and formulae.

Explore Ideas for activities and investigations to extend your understanding of the topic.

Tip Useful guidance, including on ways of calculating or checking and use of technology. Each chapter ends with a Checklist of learning and understanding and a Mixed practice exercise, which includes past paper questions marked with the icon

.

In between chapters, you will find extra sections that bring together topics in a more synoptic way. CROSS-TOPIC REVIEW EXERCISE Questions covering topics from across the preceding chapters, testing your ability to apply what you have learnt.

You will find practice paper questions towards the end of the resource, as well as a glossary of key terms (picked out in colour within the chapters), and answers. Maths is all about making links, which is why throughout this resource you will find signposts emphasising connections between different topics, applications and suggestions for further research.

Rewind Reminders of where to find useful information from earlier in your study.

Fast forward

Links to topics that you might cover in greater detail later in your study.

Did you know? Interesting or historical information and links with other subjects to improve your awareness about how mathematics contributes to society.

Colour-coding of exercises The questions in the exercises are designed to provide careful progression, ranging from basic fluency to practice questions. They are uniquely colour-coded, as shown here.

1

Find the recurrence relation for each of these sequences. a b c d

5

The Fibonacci sequence is defined by

.

a Find the first eight terms of the sequence. b Find the first seven terms of the sequence obtained by taking the differences between consecutive terms of the Fibonacci sequence. c Write down the first seven terms of the sequence obtained by taking quotients of consecutive terms of the Fibonacci sequence (as decimals to decimal places). d A rectangle has area square unit. Its length is and its width is

.

i Form a quadratic equation in and solve it to find the value of . ii Write down the name of this number. 7

In 2017 the population of the United Kingdom is taken to be million people. The annual growth rate is . In addition, it is expected that the net immigration will be people per year. Set up a recurrence system to model the population and solve it to estimate the number of people in years’ time. Show that the population of the United Kingdom in 2022 will be people.

13

A sequence is defined by Prove by induction that

, with

million

.

for all positive integers .

Verify that your proof is valid for the first five terms of the sequence. 15

A sequence is defined by Prove by induction that

, with

.

for all positive integers .

Verify that your proof is valid for the first five terms of the sequence.

Black – drill questions. These come in several parts, each with subparts i and ii. You only need attempt subpart i at first; subpart ii is essentially the same question, which you can use for further practice if you got part i wrong, for homework, or when you revisit the exercise during revision.

Green – practice questions at a basic level. Yellow – designed to encourage reflection and discussion. Blue – practice questions at an intermediate level. Red – practice questions at an advanced level.

– indicates content that is for A Level students only. – indicates content that is for AS Level students only.

Contents Introduction How to use this resource 1 Mathematical preliminaries Section 1: Classifying objects Section 2: Counting methods Mixed practice 1 2 Graphs and networks Section 1: The language of graph theory Section 2: Types of graph Section 3: Using graphs Mixed practice 2 3 Algorithms Section 1: Understanding algorithms Section 2: Comparing algorithms Section 3: Sorting and packing problems Mixed practice 3 4 Network algorithms Section 1: Least weight path between two vertices Section 2: Least weight tree connecting all the vertices Section 3: Least weight cycle through all the vertices Section 4: Least weight route using every arc Mixed practice 4 Cross-topic review exercise 1 5 Decision making in project management Section 1: Critical path analysis Section 2: Scheduling Mixed practice 5 6 Graphical linear programming Section 1: Formulating linear programming problems Section 2: Working with constraints Section 3: Graphical solutions Mixed practice 6 7 The simplex algorithm Section 1: Carrying out the simplex algorithm Section 2: Interpretation Mixed practice 7 8 Game theory Section 1: Simple two-person, simultaneous play games Section 2: Mixed strategies Mixed practice 8 Cross-topic review exercise 2 Practice paper Formulae Answers 1 Mathematical preliminaries

2 Graphs and networks 3 Algorithms 4 Network algorithms 5 Decision making in project management 6 Graphical linear programming 7 The simplex algorithm 8 Game theory Glossary Acknowledgements Copyright

1 Mathematical preliminaries In this chapter you will learn how to: classify four types of problem partition a set use the pigeonhole principle enumerate arrangements enumerate selections use the inclusion–exclusion principle.

Before you start… GCSE

You should be able to use systematic listing strategies.

GCSE

You should be able to use Venn diagrams and sets.

1 A cafeteria has a choice of three types of drink and four types of cake. In how many different ways can a customer choose a drink and a cake? 2 Draw a Venn diagram to show the set of positive integers that are less than and the following subsets. a

is odd

b

is a square number

Section 1: Classifying objects Types of problem Problems can be classified according to what is known or not known about their solution, as shown in Key point 1.1. It is not always necessary to find the ‘best’ solution: often a ‘good’ solution is sufficient for practical purposes.

Key point 1.1 Types of problem: existence: in which we want to find out whether or not a solution exists construction: where we know that a solution exists (by some means) but we want to find or construct an example enumeration: in which we want to find out how many different ways there are of doing something optimisation: in which we want to know the best way of doing something.

WORKED EXAMPLE 1.1

Use the following problem to explain the meaning of the terms: a existence b construction c enumeration d optimisation Jonah wants to go to a surfing festival that is hundreds of miles from where he lives but he needs to work an evening shift the day before the festival starts. He wants to know whether he can get to the festival campsite, with all his kit, before the festival starts. a Existence: Is it possible for Jonah to get there on time?

Sometimes we are just interested in whether or not there is at least one solution that satisfies all the constraints, without needing to find it explicitly.

b Construction: Find a specific travel plan that will get Jonah there on time.

Given that at least one solution exists, can it be constructed? This does not need to be a very good solution, just one that works. For example, you could imagine Jonah being able to find someone who could fly him to the festival in their private jet. Sometimes we might construct a solution in order to solve an existence problem – constructing a solution shows that at least one solution exists.

c Enumeration: How many different ways are there that Jonah could use to get there on time?

Most problems have many possible solutions. These might include travelling some parts of the journey by different forms of transport in various combinations.

d Optimisation: What is the ‘best’ way for Jonah to get there on time? This could mean the cheapest method or the most convenient method that gets Jonah to the festival on time.

What is meant by the ‘best route’ depends on several factors. These could include the cost, journey start time, the time Jonah will arrive at the festival, any luggage limit and so on.

WORKED EXAMPLE 1.2

You have some coins in your pocket and need to pay exactly use as few coins as possible to do this.

into a vending machine. You want to

a Why might a solution not exist? b Why might it not be possible for you to construct a solution? c How many different solutions are there when you have the following coins in your pocket? d Find the optimal solution when the coins in your pocket are as given in part c. a A solution would not exist if the total amount in your pocket was less than

For example, if you only had

and

coins.

or

if you did not have the right combination of coins to make exactly . b To construct a solution you would need to know exactly what coins are in your pocket. c

Counting the number of solutions involves a systematic consideration of all the cases.

Using and The can be made as or or or Using and The can be made as

Start with one and work through decreasing numbers of coins, and then do the same with no coins.

Start with one and work through decreasing numbers of coins, and then do the same with no coins.

or or or or In this case, there is no conflict between the coins used to make the and the coins used to make the .

For this particular set of coins, the total of the coins under is only , so there is not enough to make and another . The must be made from the larger coins.

There are four ways to make the and five ways to make the , so there are different solutions altogether. d Use

Making uses at least coins and making uses at least coins. In each case, this is achieved by using as many of the larger coins as possible.

coins.

Set notation Rewind You should have met sets and Venn diagrams in GCSE Mathematics. You need to know the set notation symbols, as shown in Key point 1.2.

Key point 1.2 Set notation: means that is an element of set .

is the number of elements in set . This is called the cardinality of set . is the set of elements that are in both and . This is called the intersection of sets and . is the set of elements that are in either or or both. This is called the union of sets and . is the set of elements that are not in set . This is called the complement of set . Set notation is given in Section 5C of the AS and A Level Further Mathematics specification.

WORKED EXAMPLE 1.3

The positive integers less than {positive integers less than {positive integers less than

are used to form two sets: that are also prime} that are also more than a prime}.

a Use set notation to write the elements in each set. b Represent the outcomes in a Venn diagram. c Find the set

.

d Find the set

.

e Find

.

a

The order of the elements within a set does not matter. Primes have exactly two distinct factors, so is not a prime number. Add to each element of , provided the result is still less than

b

A

2

c



B

3

5 7

4 9

1 6 8

A

B

2

d

7

1

4

6

9

A

8

B

2

e

3

5

3

5 7

4 9

1 6 8

.

A

B

2

3

5 7

4 9

1 6 8

You need to be able to list the partitions of a set. A partition is a way of splitting the elements of a set into non-empty subsets so that each element is in a subset (the union of the subsets is the whole set) and each pair of subsets is disjoint (have no intersection) so there is no element that is in more than one subset. WORKED EXAMPLE 1.4

List the

partitions of the set

A systematic approach helps. List the different partitions with each structure.

, , , , ,

, , ,

, , ,

.

The order of the elements within a set does not matter and the order of the sets within a partition does not matter. , , ,

Sometimes, instead of using set notation, partitions are split using vertical lines, for example, can be written as .

The pigeonhole principle Tip A pigeonhole is a box that an individual’s mail is put into in a block of flats or at a workplace. The pigeonhole principle says that if letters are put into pigeonholes, and

then there must be

at least one pigeonhole with two or more letters. WORKED EXAMPLE 1.5

Ten points are placed in a square of area within

of each other.

Divide the square into equal small squares.

. Show that there must be at least two points that are

The edge length of the big square is .

Each small square has edge length

.

This makes pigeonholes, but there are

points.

So no matter how the points are distributed, there must be at least one square with at least two points in it.

Use the pigeonhole principle.

The maximum separation of two points within a square of edge happens when they are at diagonally opposite corners. Their separation is the length of the diagonal

.

Use Pythagoras’ theorem to calculate the length of the diagonal.

EXERCISE 1A 1

The positive integers less than or equal to a Find the set

.

Two sets are defined as: a Describe the set b Write

,

.

b Find the set 2

are used to form two sets:

{multiples of },

{multiples of }

.

in a different way using unions, intersections and/or complements of sets.

3

List the partitions of the set

4

Wamil wants to make a tray of flapjacks. She has a recipe, the ingredients and a tin. Write down a question that she might ask that leads to:

. square baking

a an existence problem b an optimisation problem. 5

From the set of positive integers that are less than , sets and are defined as { is a multiple of }, { is a multiple of }. a List the elements in the set

.

b Find the number of elements in the set The upper limit is increased to c Find

.

, so that the set

is being used.

.

6

List all the partitions of

7

Ben plays a game with a standard six-sided dice, numbered in the usual way so that opposite numbers add up to .

.

He starts with a on the top face and turns the dice through

(in any direction) so that one of the

side faces becomes the new top face. Ben continues in this way, adding the numbers on the top face together. For example, after two turns his score might be . He wants to get a score of exactly using as few turns as possible. a Construct a solution, starting with and totalling

. Your solution does not need to be optimal.

b Explain how you know that it is possible to enumerate the number of ways of getting a score of starting from . You do not actually need to find how many such solutions there are. c Show that it is impossible to get a score of

,

in three turns, starting with .

d Find an optimal solution. 8

Prove that if you pick

9

a Show that if any nine numbers are chosen from the numbers to them for which the smaller is a factor of the larger.

numbers from the integers to

, then two of them must sum to

.

, there must be at least two of

b When any numbers are chosen from the numbers to , there must be at least two of them for which the smaller is a factor of the larger. Find the smallest possible value of that fits this description. 10 There are several people in a room. Some pairs are acquaintances and others are not. Use the pigeonhole principle to show that there are at least two people in the room who have the same number of acquaintances amongst the people in the room. 11 Five jobs, to , need to be carried out. Each job is to be done by one person with a fixed starting time and a fixed finishing time. All the people available can do any of the jobs but a person can only do one job at a time. Job Start Finish a Which jobs cannot be done by the person who does job ? b Find all the valid ways to partition the jobs between up to five people. c What is the minimum number of people needed to carry out the five jobs? 12 What is the maximum number of points that can be placed in a square of area points are closer to each other than

?

so that no two

Section 2: Counting methods Arrangement and selection problems The multiplicative principle says that if there are ways of doing one thing, and for each of these there are ways of doing another thing, then there are different ways of doing both things. This can be extended to three things, with, respectively, different ways of doing all three.

and ways of doing each, giving

WORKED EXAMPLE 1.6

When I buy an ice cream I choose up to three scoops. The scoops are stacked one on top of each other. Each scoop could be any of my favourite flavours, except that I do not want two scoops of the same flavour next to one another. How many different ice creams are possible? There are

ice creams

My ice cream has

or scoops.

with scoop. There are ice creams with scoops.

The second scoop must be different from the first.

There are ice creams with scoops.

The third scoop must be different from the second but could be the same as the first.

different ice creams are possible. It can be useful to enumerate the number of solutions to a problem because if this number is large it is not sensible to try to list all the solutions. WORKED EXAMPLE 1.7

Three athletes, Amy, Brooke and Chahna, run a race. They finish in the first three positions, with no tied places. a List the six possible finishing orders. b Show how the number of arrangements can be calculated. c Work out the number of different arrangements of a





b

and .

Where, for example, means that Amy finished first, Brooke finished second and Chahna finished third. There are three options for the athlete who finished first, for each of these there are two options for the athlete who finished second, leaving one option for the athlete who finished third.

c

Tip The product

can be written using pi notation as

. This notation means multiply

together the values of when and , i.e. . The product can also be written using factorial notation as You should be able to calculate factorials using your calculator. An arrangement of distinct objects is a rearrangement of the objects.

There are of a subset of distinct objects is needed.

arrangements of distinct objects. Sometimes an arrangement

WORKED EXAMPLE 1.8

Five athletes,

and , run a race.

a How many different finishing orders are there for st, nd and rd places? b List the finishing orders for st, nd and rd places when finishes st. a

choices for the athlete who finished st.

The multiplicative principle can be used.

choices for the athlete who finished nd. choices for the athlete who finished rd. b

There are arrangements that start with (and another start with each of and ).

that

The number of arrangements of objects from distinct objects is called the number of permutations of objects from and is written as or , as shown in Key point 1.3.

Key point 1.3

In an arrangement, the order of the objects matters so, for example, and are different. Sometimes all that is required is the number of ways of selecting subsets of a certain size from a set of distinct objects (when the order in which the objects are chosen does not matter). WORKED EXAMPLE 1.9

A bag contains five balls, labelled and . Balls are taken from the bag and not replaced. How many ways are there of selecting three balls from the five in the bag? The selections can be listed:

The order of the letters in each triple does not matter. The selections are subsets of the original set.

There are just

Each of these selections is a triple of letters. These letters can be rearranged in ways to give the permutations of objects from .

ways of

selecting objects from distinct objects.

The number of selections of objects from distinct objects is called the number of combinations of objects from and is written or , as shown in Key point 1.4.

Key point 1.4 so

Tip

You may be able to calculate

and

directly on your calculator. If not, they can be

calculated using Problems may be set where the objects are not all distinct (there are repetitions) or where other restrictions apply. WORKED EXAMPLE 1.10

a Find the number of arrangements of the letters

.

b Find the number of arrangements of the letters

if the two

a If the two are different, say, then there would be arrangements. There are

and

arrangements of

, so the

,

and

arrangements can be split as

sets that only differ in the labelling of

and

cannot be next to one another.

Each arrangement where occurs before can be paired with another that is exactly the same, except that occurs before , for example and .

.

If the two are not distinct, there are arrangements. b If the first letter is , then the only possibility is . Similarly, there is only one possibility if the first letter is . If the first letter is , then the second letter can be or , and the two remaining letters can be in either order. This gives another

These can be listed as:

The easiest way might be to write out the possibilities or to look at the list from part a and exclude the arrangements where the two are next to one another. For example,

or

.

possibilities.

arrangements with two not next to one another.

These can be listed as: .

Problems involving finding the number of arrangements of a subset when the objects are not all distinct and problems with several constraints are beyond AS Level but may be asked at A Level. WORKED EXAMPLE 1.11

Find the number of arrangements of three letters from the set gives arrangements. gives

.

There are two cases to consider, namely, when the three letters are all different and when both are included. With

for example, the can be first, second or third: .

arrangements. gives arrangements. arrangements of

These can be listed as:

letters from

The inclusion–exclusion principle WORKED EXAMPLE 1.12



WORKED EXAMPLE 1.12

Some children were asked whether they had ever been to France and whether they had ever been to the USA. of the children had been to France and had been to the USA. These figures included children who had been to both France and the USA. a How many of the children had been to France or the USA? The children were then asked whether they had ever been to Australia. of the children had been to Australia. This number included children who had been to both France and Australia and children who had been to both the USA and Australia, of whom had been to all three countries. b How many of the children had been to at least one of the three countries? a

so

b

to and another

to

so

had been to but not , so had been to and but not . Of the who had been to but not , only had not also been to .

The inclusion–exclusion principle can be used to count the number of elements in a union of two sets. At A Level, this may be extended to unions of three or more sets, as shown in Key point 1.5.

Key point 1.5 The inclusion–exclusion principle:

and so on, alternately including terms of the form , excluding terms of the form including terms of the form , excluding terms of the form

, , etc.

At A Level, the inclusion–exclusion principle can be used to count the number of derangements of an ordered list. A derangement is an arrangement of an ordered list in which no element is in its original position.

Tip You are not required to learn any results about counting derangements. Informal methods may be used.

WORKED EXAMPLE 1.13

The letters of the word CODE are rearranged to form new four-letter ‘words’. a How many of the words formed do not start with the letter ? b How many of the words formed do not have either or in their original positions? c How many of the words formed do not have any of the letters in their original positions? a There are these, b

words altogether. Of start with so words do not start with .

words that do not have either or in their original

If a word starts with C, the other three positions can be filled in ways.

words, of which have first, have second and start with .

positions. c There are derangements.

The derangements are:

There are ways to choose letter. Put this letter in its original position. There are ways to rearrange the other three letters. There are ways to choose letters. Put these letters in their original positions. There are ways to rearrange the other two letters. And so on.

The calculation can be simplified to: or

EXERCISE 1B 1

How many different four-digit numbers can be made using each of the digits

2

How many ways are there to select four letters from an alphabet of chosen more than once?

3

How many times does the digit appear in a list of the positive numbers from to

4

Amy has five different tops and four different skirts.

once?

letters if letters may not be

?

a How many different outfits (consisting of a top and a skirt) can Amy make? Amy does not want to wear her chiffon blouse with her denim skirt. b How many different outfits can Amy make with this additional restriction? 5

a How many ways are there of selecting three digits from the number

?

b How many three-digit numbers can be formed as arrangements of three digits from the number ? c How many of the three-digit numbers from part b are even? 6

a Alan, Bao, Charlie, Donna, Emma and Fatima sit in a row on a bench. In how many different ways can they be seated? b The same six people sit around a table, as shown. Donna needs to sit in the seat labelled D. In how many different ways can the other five be seated?

D

c In how many ways can the other five be seated around the table if Alan wants to sit next to Emma (on a long side or on a corner) and Charlie does not want to sit on an end (short side) of the table? 7

In how many of the arrangements of the list is immediately followed by ? For example, in and it is but in it is not.

8

In a survey about travel to work, people were asked what methods of travel they had used that morning for at least one mile of their journey to work. people said car, said walk, said bus

and said train. Of these, said car and bus, said car and train, said walk and bus, said walk and train. Nobody said both car and walk and nobody said both bus and train. people said that they did not use any method of travel for at least one mile of their journey. How many people replied to the survey? 9

Write out all the derangements of the list

10 Digits are chosen from the set

. so that they add up to

. Each digit can be

chosen only once (apart from which can be chosen twice). a How many ways are there to select digits from this set so that they add up to

?

The digits that have been chosen are used to form numbers. The lead digit cannot be , so, for example, if the numbers chosen are the numbers that can be formed are and . b What is the largest number that can be formed? c How many of the numbers are multiples of ? d How many of the numbers are less than 11 a How many of the positive integers from to b How many of the positive integers from to

? are divisible by or or both? are not divisible by any of

and

?

12 a How many six-letter ‘words’ can be made using the letters of the word BANANA? b How many four-letter ‘words’ can be made using the letters AABBCCDDEEFF?

Checklist of learning and understanding Problems can be classified according to what is known, or not known, about their solution. It is not always necessary to find the ‘best’ solution: often a ‘good’ solution is sufficient for practical purposes. Existence: it is known that there is a solution, or solutions, but that is all. Construction: a solution can be found, but it might not be a ‘good’ solution. Enumeration: the number of different solutions can be worked out. Optimisation: the ‘best’ solution, according to some criteria, can be found. Set notation: means that is an element of set . is the number of elements in set . This is called the cardinality of set . is the set of elements that are in both and . This is called the intersection of sets and . is the set of elements that are in either or or both. This is called the union of sets and . is the set of elements that are not in set . This is called the complement of set . A partition is a way of splitting the elements of a set into non-empty subsets so that each element is in a subset (the union of the subsets is the whole set) and each pair of subsets is disjoint (have no intersection) so there is no element that is in more than one subset. The pigeonhole principle says that if letters are put into pigeonholes, and there must be at least one pigeonhole with two or more letters.

, then

The multiplicative principle says that if there are ways of doing one thing, and for each of these there are ways of doing another thing, then there are things.

different ways of doing both

This can be extended to three things, with, respectively,

and ways of doing each, giving

different ways of doing all three. An arrangement of distinct objects is a rearrangement of the objects. There are

arrangements of distinct objects.

The number of arrangements of objects from distinct objects is called the number of permutations of objects from and is written as or

The number of selections of objects from distinct objects is called the number of combinations of objects from and is written

or

.

The inclusion–exclusion principle A derangement is an arrangement of an ordered list in which no element is in its original position.

Mixed practice 1 1

Hugh is a television addict. He has been invited out for the evening so he has marked the television programmes that he wants to record in the TV guide. Some of the programmes are repeated an hour later on the channels and some of the programmes will be available the next day on ‘catch-up’. Hugh can record at most programmes at any one time. He wants to record all the programmes that he has marked in the TV guide. a Describe a situation for which a solution does not exist. The table shows the start time and length of the programmes that Hugh wants to record, whether they are available on (which means that the start time is hour later) and whether they will be available the next day on catch-up. The times are given in hours. Programme Start Length

Catch-up

































b Construct a solution for Hugh. 2

{

is times a prime number},

a List an element of b Explain why 3

{

is more than a prime number}

. .

Seven athletes, A to G, run a race. The track has eight lanes ( to ). Each athlete will run in a different lane and one lane will be empty. A starting order is a listing of the athletes in lane order (from lane to lane ). For example, .

, where the empty lane is denoted by

a How many different starting orders are possible? b How many different starting orders are possible if the empty lane is either lane or lane ? 4

a Explain why there are just two derangements of the word

.

b By considering the position of in a derangement, enumerate the number of derangements of the word . You should not list the derangements. 5

a How many different five-digit numbers can be made using each of the digits of the number ? b How many of these are divisible by

6

?

a How many different six-digit numbers can be made using each of the digits of the number ? b How many different six-digit numbers can be made using the digits of the number

?

c How many different six-digit numbers can be made using the digits of the number in which no two adjacent numbers are the same? 7

Joe has seven socks. Each sock is a different colour of the rainbow

. Joe

partitions the socks between three boxes, putting at least one sock in each box. The boxes are indistinguishable. a

i Write a partition where one box has as many socks as possible. ii How many different partitions are of this type?

b

i Write a partition in which the numbers of socks in the boxes are as equal as possible. ii How many different partitions are of this type?

c How many different partitions are there? 8

How many of the positive integers from to

9

Seven positive integers are chosen.

are divisible by at least one of , and ?

a Explain why there must be at least two of the numbers for which the difference of their squares is a multiple of . b How many positive integers are needed to ensure that there are at least two of them for which the difference of their squares is a multiple of ? 10 A round table has

seats. King Arthur sits in one of the seats. Ten knights enter the room and

sit at the table. The final seat is taken by Queen Guinevere. a How many arrangements are possible if Queen Guinevere sits opposite King Arthur? Five of the knights wear purple tunics and the other five wear silver tunics. b How many arrangements are possible if Queen Guinevere sits opposite King Arthur and no knight sits next to another wearing the same colour tunic? c How many arrangements are possible if no knight sits next to another wearing the same colour tunic, but Queen Guinevere need not necessarily sit opposite King Arthur?

2 Graphs and networks In this chapter you will learn: the terminology of graphs and networks about some special types of graphs what isomorphism means what is planarity what is a digraph how graphs and networks can be used to model problems.

Before you start… GCSE

You should be able to represent relationships.

1 What relationship is shown in this mapping?

one two three four

3 4 5 6

Section 1: The language of graph theory Terminology and notation A graph is a set of vertices connected by arcs. A vertex (or node) is shown as a point in the graph. Vertices may be labelled or not. An arc (or edge) is a line or curve with a vertex at each end. Two vertices are directly connected, or adjacent, if there is an arc with these vertices at its ends. An arc that directly connects to itself is called a loop. An indirect connection between two vertices passes through other vertices and involves more than one arc. WORKED EXAMPLE 2.1

A

D C

B

E

a How many vertices does this graph have? b List the five arcs in the graph. c Which vertices are adjacent to ? d Write down an indirect connection between and . a

The vertices are

b

An arc can be identified by the vertices at its ends. Arc , for example.

and c

and

d

and . is the same as

The vertices that are directly connected to . Or

.

It is usual to avoid repeating vertices, unless this is necessary for a particular problem. The position of the vertices and the shapes of the arcs in a graph (including whether they cross each other or not) are irrelevant. All that matters is which vertices are adjacent (directly joined) to each other. A graph is connected if it is possible to get from any vertex to any other, directly or indirectly. A graph is simple if there is exactly one arc between any two adjacent vertices and there are no loops. A graph that is both simple and connected is said to be simply connected. The degree of a vertex is the number of arcs at that vertex (the number of arcs incident on the vertex). WORKED EXAMPLE 2.2

a What is the degree of each vertex in the graph shown in Worked example 2.1? b Work out the sum of the vertex degrees. c Why is the sum of the vertex degrees twice the number of arcs? a

b

and each have degree . has degree . and each have degree .





c Each arc has two ends, each of



which contributes towards a vertex degree. The sum of the vertex degrees is the total number of arc endings, which is the same as twice the number of arcs.

Key point 2.1 For any graph, the sum of the vertex degrees is twice the number of arcs. A consequence of this is that a graph cannot have an odd number of vertices with odd degrees. (This is called the handshaking lemma.)

A simply connected graph with the minimum possible number of arcs is called a tree.

Key point 2.2 A tree on vertices has

arcs.

WORKED EXAMPLE 2.3

There are two different trees with four vertices. a Draw the two different trees with four vertices. b List the set of vertex degrees for each tree. a

b

Any other tree on four vertices can be rearranged by moving the vertices around to make one of these graphs. and .

The trees have different sets of vertex degrees so they must represent different graphs.

The vertices at the ends of the branches in a tree have degree . A tree on vertices must have a minimum of two vertices of degree and a maximum of vertices of degree . A subgraph of a graph is formed using some of the arcs of the graph together with the vertices that these arcs connect and, possibly, some other unconnected vertices. A walk is a connected subgraph consisting of a set of arcs where the end vertex of one arc is the start vertex of the next. A trail is a walk in which no arcs are repeated. A path is a trail in which no vertex is repeated. A cycle is a closed path (a path with an extra arc that joins the end vertex back to the start vertex). A route is a general term used to mean any of the aforementioned terms.

Fast forward The terms path, tree, cycle and route will be useful for network problems in Chapter 4.

WORKED EXAMPLE 2.4

a Using the graph shown, give two examples of each of the following.

A

D C

B

E

i a walk that is not also a trail ii a trail that is not also a path iii a path b Using the graph in part a, give an example of a cycle. a

i For example:

This needs to be a connected ‘string’ of arcs with at least one arc repeated.

and . ii For example:

This needs to be a connected ‘string’ of arcs with no arcs repeated but at least one vertex repeated.

and . iii For example: and

This needs to be a connected ‘string’ of arcs with no vertices repeated.

.

b For example:

.

This is the only cycle, although it can be started at any vertex and travelled in either direction; for example: .

Complete graphs A simply connected graph with the maximum possible number of arcs is called a complete graph (see Key point 2.3).

Key point 2.3 The complete graph with vertices is denoted by

and has

arcs.

WORKED EXAMPLE 2.5

Draw the graph

.

For example: A

B

C

can be drawn without arcs crossing, for example: W

Y

X

Z

D

The vertices need not be labelled.

Bipartite graphs The vertices of a bipartite graph can be partitioned into two sets so that every arc joins a vertex from one of these sets to a vertex in the other set. No arc connects two vertices that are in the same set. A simply connected bipartite graph with the maximum possible number of arcs is called a complete bipartite graph (see Key point 2.4).

Key point 2.4 The complete bipartite graph with vertices in one set and vertices in the other set is denoted by . Each of the vertices in the first set is connected to each of the vertices in the second set, so has arcs.

The classic ‘utilities problem’ where three houses need to each be connected to three utilities: gas, water and electricity, without any of the connections crossing uses the complete bipartite graph

.

WORKED EXAMPLE 2.6

Draw the graph

. The two sets are usually presented either as two horizontal rows or as two vertical rows, so that the two sets can be easily identified. The vertices need not be labelled.

For example: A

B

D

C

E

F

At A Level, a ‘colouring algorithm’, may be used to show whether a given graph is, or is not, bipartite (not necessarily complete bipartite) or to find a subgraph that is bipartite. There are several such colouring algorithms and you are not expected to learn any of these. When a colouring argument is required it will always be given. WORKED EXAMPLE 2.7

Apply the following colouring algorithm to show that this graph is bipartite.

U

V

X

Y

W

Z

• STEP 1 Choose any vertex as the starting vertex and colour it red. • STEP 2 Colour every vertex that is adjacent to a red vertex as blue. • STEP 3 Colour every vertex that is adjacent to a blue vertex as red. • STEP 4 If a vertex is coloured both red and blue STOP; the graph is not bipartite. • STEP 5 Continue steps 2, 3 and 4 until either a vertex is coloured both red and blue or no more vertices can be coloured. • STEP 6 If no vertex is coloured both red and blue and there are vertices that have not yet been coloured, go back to step 1. If every vertex is coloured either red or blue and no vertex is coloured both red and blue STOP, the graph is bipartite. STEP 1  

red

Any vertex can be chosen as the start vertex.

STEP 2   blue

blue,

Vertices adjacent to are coloured blue.

STEP 3   red, red

Vertices adjacent to or are coloured red.

red,

All vertices are coloured. The red vertices form one set and the blue vertices form the other set.

STEP 6   Graph is bipartite.

EXERCISE 2A 1

List the vertex degrees for this graph. A

C

E B

2

D

Using the graph in question 1, give an example of each of the following. a a path through all five vertices b a cycle through all five vertices c a tree that connects all five vertices

3

Explain why the graph in question 1 is not simply connected.

4

a How many arcs does

have?

b Describe how to make from the graph in question 1 by removing one vertex (and the arcs that are incident on it) and adding one arc. 5

a What is the sum of the vertex degrees for a tree on five vertices? b What is the minimum possible vertex degree for a tree on five vertices? c What is the maximum possible vertex degree for a tree on five vertices? d List the possible sets of vertex degrees for trees on five vertices.

6

A graph is drawn with vertices multiple of the smaller.

and . Arcs connect two vertices if the larger is a

a Draw this graph. b List a cycle in this graph. c List a path that starts at and travels through every vertex in the graph. 7

The graph connects six vertices.

a Using subgraphs of this graph, find three different trees connecting the six vertices. b Show that the trees are different using the vertex degrees for your trees. 8

A simply connected graph has six vertices. Five of the vertex degrees are , , , and a Explain why the missing vertex degree must be odd. b What is the missing vertex degree if the graph has eight arcs?

c What is the maximum possible number of arcs that the graph could have? 9

a Explain why it is impossible to draw a graph with vertex degrees , , , and . b Explain why there is no simply connected graph with vertex degrees , , and A graph has three vertices, , and with vertex degrees c Find the possible values for

and , respectively.

and if the graph is:

i simple ii connected iii simply connected 10 a Use the colouring algorithm from Worked example 2.7, starting from vertex , to show that the following graph is bipartite.

Z

Y

S

X

T

W U

V

b List the two sets into which the vertices are partitioned. 11 For each of the following vertices, how many different trees can be made as subsets of a

vertices

b

vertices

c

vertices

12 Explain why

has

arcs.

Rewind can be summed using the formula for triangular numbers or using the result for an arithmetic series from A Level Mathematics Student Book 2, Chapter 4.

?:

Section 2: Types of graph Eulerian graphs A traversable graph is one that can be drawn without taking your pen from the paper and without going over the same arc twice. WORKED EXAMPLE 2.8

Which of the following graphs are traversable? A

B

C

D

At this stage just use trial and improvement to try to find traversable paths.

, and

An Eulerian graph has no vertices with odd degree. Eulerian graphs are traversable (with the same start and finish point). A semi-Eulerian graph has exactly two vertices with odd degree. Semi-Eulerian graphs are semi-traversable (traversable with different start and finish points).

Hamiltonian graphs A Hamiltonian graph contains a cycle that passes through every vertex (exactly once, apart from the start and finish being the same). Usually there will be arcs in the graph that are not used in the cycle. WORKED EXAMPLE 2.9

In chess, a knight moves two squares horizontally followed by one square vertically or two squares vertically followed by one square horizontally. A classic chessboard puzzle, known as the knight’s tour, asks whether a knight can visit every square of an

chessboard and whether this can be done with the knight finishing back where it started. There are several possible solutions.

WORKED EXAMPLE 2.10

Draw a Hamiltonian cycle on the edges of a cube. A possible solution is shown.

Ore’s theorem says that, for a simply connected graph, , with vertices, if the sum of the vertex degrees for every pair of non-adjacent vertices, then is Hamiltonian.

Tip Satisfying the condition in Ore’s theorem is sufficient to ensure that a graph is Hamiltonian but the condition is not necessary. There are Hamiltonian graphs that do not satisfy the condition in Ore’s theorem, so, if the condition is not satisfied, you cannot conclude whether the graph is Hamiltonian or not.

WORKED EXAMPLE 2.11

a Find the minimum sum of the vertex degrees for pairs of non-adjacent vertices for each of the following graphs.

A

C

B

E

D

b Use Ore’s theorem on each of the graphs shown, stating your conclusions. a

Every vertex has degree so each non-adjacent pair has degree sum Two vertices have degree and four have degree . There are pairs of nonadjacent vertices of degree (for example, top left and top right), so the minimum sum is . : There are no non-adjacent vertices. One vertex has degree and four have degree . There are pairs of nonadjacent vertices of degree (for example, top left and top right) so the minimum sum is . The vertices of degree are adjacent to one another but only to two of the vertices of degree .

b

: Ore’s theorem is inconclusive. : Ore’s theorem shows that is Hamiltonian. : Ore’s theorem cannot be used. : Ore’s theorem is inconclusive. : Ore’s theorem

but Ore’s theorem is inconclusive, although the graph is Hamiltonian. and

Graph is Hamiltonian but has no non-adjacent vertices. but Ore’s theorem is inconclusive; in this case, the graph is not Hamiltonian. and

shows that is Hamiltonian.

Explore Hamiltonian graphs are named after the Irish mathematician William Hamilton (1805–1865) who

.

invented the icosian game, which is now known as Hamilton’s puzzle. This involves finding a Hamiltonian cycle in the edge graph of a dodecahedron. Draw a -dimensional skeleton graph of a dodecahedron and investigate this problem. Show that all Platonic solids when considered as graphs have Hamiltonian cycles.

Isomorphism Two graphs are isomorphic if they have the same structure.

Tip From the ancient Greek: isos equal, morphe form or shape. The graphs might look different from one another but they can be transformed into one another by relabelling and moving the vertices and arcs around without cutting any of the arcs. Isomorphism can be shown using a reasoned argument or by setting up a correspondence between the vertex sets. WORKED EXAMPLE 2.12

Show that these graphs are isomorphic. W

Y

A

C

X

Z

B

D

Straighten out arc

Set up a correspondence between the vertex sets.

and relabel the vertices:

WORKED EXAMPLE 2.13

Show that these graphs are isomorphic. A U

V

W

D

C

E

F

X

Y

Relabel and

B

.

Z

Compare the vertex degrees to suggest a possible correspondence.

The degree sequence of a graph is a list of the vertex degrees, written in increasing order. Having the same degree sequence is a necessary condition for two graphs to be isomorphic, but it is not sufficient. Two graphs can have the same degree sequence but not be isomorphic. WORKED EXAMPLE 2.14

Draw two non-isomorphic graphs that each have degree sequence

.

These trees each have the same degree sequence but the lengths of the branches are different.

EXERCISE 2B 1

Explain why a tree can never be Eulerian.

2

Record the degree sequence for this graph.

3

Is the graph in question 2 Eulerian, semi-Eulerian or neither? Explain your reasoning.

4

Which of these graphs are isomorphic? A.

B.

C.

5

This question is about the seven graphs: A. B. C. D. E. F. G. a How many arcs do each of these graphs have? b Which of the seven graphs are Eulerian?

6

a Give an example of a graph that is Hamiltonian but not Eulerian. b Give an example of a graph that is Eulerian but not Hamiltonian.

7

There are six non-isomorphic trees with six vertices. Draw an example of each and give its degree sequence.

8

A simply connected Eulerian graph connects five vertices using six arcs. a Give the degree sequence for the graph.

b How many non-isomorphic graphs are there that fit all the requirements? 9

a Are complete graphs Hamiltonian? b Are complete bipartite graphs Hamiltonian?

10 Describe what happens when Ore’s theorem is applied to complete bipartite graphs 11 A simply connected graph has six vertices and eight arcs. The degree sequence for the graph is , where . a Write down the constraints that the integers

and must satisfy.

b Show that the graph is not Eulerian. c Show that the graph is not semi-Eulerian. d By considering the value of , show that the graph is not Hamiltonian. e Find all the possible values of

and .

12 A graph has degree sequence , , , . a How many arcs does the graph have? b Explain why the graph is not simply connected. c How many non-isomorphic graphs are there with this degree sequence?

Section 3: Using graphs Digraphs A graph with directed arcs is called a digraph. The arcs in a digraph must all be directed, so any undirected arc connecting two vertices must be replaced by a pair of arcs, with one going each way (like a dual carriageway). A loop, from a vertex to itself, can just be made into a directed arc.

B A

D

C In a digraph, each vertex is split into two parts: the in-degree and the out-degree. The in-degree is the number of arcs that come in at the vertex and the out-degree is the number of arcs that come out of the vertex. WORKED EXAMPLE 2.15

A graph connects four vertices:

and .

There are directed arcs from to each of and an undirected arc joining to .

and and from to . There is a loop from to itself

a Find the in-degree and the out-degree for each vertex. b What is the relationship between the total in-degree, the total out-degree and the number of arcs? a The digraph has arcs:

There are arcs in at and out. and

. Vertex In-degree

There is arc in at (from ) and out (to ). There are arcs in at and out (the loop is both an in and an out). There are arcs in at and arc out.

Outdegree b Total in-degree total out-degree number of arcs

Vertex

Total

In-degree Out-degree Total

Planar graphs WORKED EXAMPLE 2.16

Give two reasons why it is useful to be able to draw a graph without having any arcs crossing.



Two arcs crossing could look like a vertex where four arcs meet. Having arcs crossing can create practical problems.

Avoids ambiguity about whether there is a vertex where arcs cross or if there is a ‘bridge’. Avoids contamination between arcs, for example, short-circuits in an electrical component.

A planar graph is any graph that can be drawn with no arcs crossing (can be drawn as one layer).

Tip A planar graph need not actually be drawn with no arcs crossing. All that matters is that it can be manipulated (topologically) into a graph with no arcs crossing.

WORKED EXAMPLE 2.17

A simply connected planar graph is drawn on six vertices. The graph has the maximum possible number of arcs. Draw a graph that fits this description. For example:

The maximum possible number of arcs is

.

A complete graph with vertices has arcs, but some of these cross. You should be able to convince yourself that arcs is impossible for a planar graph on vertices.

Subdivision means inserting a vertex of degree into an arc, so a subdivision of

would be the graph of

with an extra vertex inserted into an arc. There may be several such extra vertices, but is hidden within the graph. In a similar way, containing a subgraph that is a subdivision of means that is hidden somewhere within the graph. Contraction means removing an arc from a graph and merging the two vertices that it previously joined. The new (merged) vertex is labelled with the labels of both vertices that were merged (e.g. combining adjacent vertices and would make a merged vertex directly joined to each vertex that was formerly adjacent to either or ). A contraction of a planar graph is always planar, so if you find a contraction of a graph that is non-planar, then must be non-planar (Wagner’s theorem). Kuratowski’s theorem says that a necessary and sufficient condition for a finite graph to be planar is that it does not contain a subgraph that is a subdivision of

or

.

The graphs and are minimum cases for non-planar. If either of these is contained within a graph, then the graph is also non-planar. Although Kuratowski’s theorem is used to show non-planarity, and you can also use it to show planarity, it is often easier to show that a graph is planar by construction; that is, by just drawing a planar representation. WORKED EXAMPLE 2.18

a Use Kuratowski’s theorem to show that the following graph is planar.

A

G

B

F

C

E

D

b Describe how the graph can be drawn with no arcs crossing. c An arc is added connecting to . Show that the graph is now non-planar. a Only a subgraph.

have degree

so

is not

If is a subgraph, there must be five vertices with degree or more.

Vertex can be removed by contraction with . This leaves a graph with six vertices: and is adjacent to , and , so and would need to be in the same set. This partitions the vertices as sets and . But is not adjacent to , so subgraph.

If is a subgraph, the vertices (of the graph formed by contraction of ) can be split into two sets of three, where each vertex in the first set is adjacent to each vertex in the second set.

is not a

Hence the graph is planar.

Graph does not contain a subgraph that is a subdivision of or .

b For example, change the arc passes outside of ; the arc

so that it so that it

passes outside of and ; the arc that it passes outside of ; and arc that it passes outside and .

When vertices may be formed by contraction it is less ambiguous to refer to arcs this way.

so so

c When arc is added and is removed by contraction, vertices and each have degree . If is a subgraph, then the subgraph must have been formed by removing one vertex and the arcs incident to it, leaving the other five vertices each with degree . This is not possible, so is still not a subgraph. The partition , shows that is a subgraph (each of and are adjacent to each of and ). is a subgraph of the reduced graph so the graph is non-planar.

cannot be removed because it would leave with degree . If is not removed, then neither are and , since the removal of any of these would leave with degree . So and are not removed, but and are each adjacent to so the removal of either of these would leave with degree .

is not adjacent to , and is not adjacent to . So if is a subgraph, the partition must have and in one set and and in the other. Both and are adjacent to each of and , so one of and can be put with and , and the other with and .

If a graph is non-planar, it cannot be drawn on a single sheet. The thickness of a graph is the minimum number of sheets on which it can be drawn. Formally, the thickness is the minimum number of planar graphs into which the arcs can be partitioned. WORKED EXAMPLE 2.19

a By partitioning the arcs of b Show that

into two planar graphs, show that

has thickness .

has thickness .

a For example:

= is non-planar so thickness . But the arcs can be partitioned into two planar subgraphs, by construction, so thickness So has thickness . b Similarly, is non-planar but it can be partitioned into two planar graphs. For example:

The thickness is if the graph cannot be drawn on one layer but can be drawn on two. and are known to be nonplanar from Kuratowski’s theorem. With this partitioning, the first layer has arcs crossing, but it could be drawn on a single layer.

= WORKED EXAMPLE 2.20

A cube has faces,

edges and vertices.

a Count the number of faces, edges and vertices for: i a tetrahedron (triangular-based pyramid) ii a square-based pyramid iii an octahedron (eight triangular faces, like two square-based pyramids joined) iv a hexagonal prism (a prism with hexagonal cross-section) b Use your results to conjecture a relationship between the number of faces, edges and vertices of a convex polyhedron. a

Faces Edges Vertices Cube i ii iii iv

b faces − edges + vertices

Or any equivalent version of this.

The edges of a convex polyhedron can be represented by the arcs in a planar graph. The faces of the polyhedron are represented by regions (one of the faces is represented by the region that is ‘outside’ the graph). Euler’s relation says that for any convex polyhedron or any planar graph

where is the number of vertices, is the number of regions (faces) and is the number of edges. WORKED EXAMPLE 2.21

The following planar graph has vertices and edges.

a Use Euler’s relation

to deduce the number of regions.

b Identify each region by listing the vertices that define it. a so

regions

so

b The regions are and .

For example, move is the outside region.

so that it hangs below then

Euler’s relation holds for all planar graphs. A non-planar graph could also satisfy Euler’s relation, but if Euler’s relation fails then the graph must be non-planar.

Using graphs and networks It is useful to have a way of describing graphs, particularly large ones. An adjacency matrix shows the number of arcs that directly join pairs of vertices. An adjacency matrix can also be used when there are no vertex labels given. WORKED EXAMPLE 2.22

a Draw the graph represented by this adjacency matrix.

b What is the significance of the row sums and the column sums of the adjacency matrix? c If a loop is drawn at vertex , how would this be represented in the adjacency matrix? a A

D C

B

E

b The row sums are the same as the corresponding column sums and give the vertex degrees.

Tip For an undirected graph, the adjacency matrix is symmetrical about the leading diagonal (top left to bottom right).

Sum

 Sum

c A loop contributes to the degree of a vertex, so it is represented by an entry in the adjacency matrix.

For an undirected graph.

Key point 2.5 In the adjacency matrix for a digraph, the rows show ‘from’ the vertices and the columns show ‘to’ the vertices.

WORKED EXAMPLE 2.23

a Construct the adjacency matrix for the digraph with four vertices , , and with arcs from to each of , and and from to , a loop from to itself, and an undirected arc joining to . b How are the in-degrees and out-degrees shown in the adjacency matrix? a         to

from 

First a digraph must be formed. The loop is shown as a directed arc from to itself and the undirected arc is shown as two arcs: one from to and one from to . Note that in a digraph a loop is represented by an entry in the adjacency matrix.

b The column sums give the indegrees and the row sums give the out-degrees. Graphs are useful in modelling problems but, more often, problems are modelled using networks. A network is a weighted graph. This means that the arcs of the graph have numerical values (weights) attached to them. The weights may, for example, represent the distances between the points represented by the vertices. The arcs in a network might be directed or undirected, although it is unusual to have loops in a network. A simple network can be represented using a weighted matrix, showing the weight of each arc and a blank, – or for vertices that are not adjacent. If the weights represent distances, this may be called a distance matrix; if the weights represent costs, it may be called a cost matrix; if the weights represent travel times it may be called a travel time matrix, and so on.

Fast forward Networks will be used to model problems in Chapter 4.

EXERCISE 2C 1

Write down the in-degree and out-degree for each vertex of this graph.

C

A

B 2

Use Euler’s relation for the planar graph

3

Show that the graph in question 1 is Eulerian.

4

Show that the graph represented by this adjacency matrix

to find the number of regions.

a is not a digraph b is semi-Eulerian 5

A standard dice is modelled as a planar graph with vertices labelled and . The faces of the dice are represented by the vertices of the graph and arcs connect vertices that correspond to adjacent faces, but not vertices that correspond to opposite faces. Use Euler’s formula to find the number of regions in the graph.

6

a Draw the network represented by the following weighted matrix, which shows travel times (in minutes) between four houses.

b Find the quickest route that includes all four houses. 7

a Write down the in-degree and out-degree for each vertex of the graph with this adjacency matrix.         to

from 

b Use the in-degrees and out-degrees to show that the graph is not Hamiltonian. 8

A medieval river crossing puzzle involves a farmer, a wolf, a goat and a sack of cabbages. Initially, the farmer, wolf, goat and sack of cabbages are together on the north bank of the river. The farmer can use a small boat to cross the river. The boat is only big enough to carry the farmer and one of the other three items. The goat cannot be left with the cabbages or with the wolf, unless the farmer is also present. The wolf can be left alone with the cabbages. The problem is to find a way to get everything across to the other side of the river using as few crossings as possible. The problem can be modelled using a graph in which the vertices are labelled to show what is on the north bank of the river at the beginning of each crossing. Initially, the farmer and all the items are all on the north bank; this is the vertex . The first crossing must involve the farmer taking the goat across the river, so the second vertex is . The final crossing must involve the farmer taking the goat from the north bank to the south bank. This is the vertex .

a List the nine possible vertices, remembering that the goat cannot be left with the cabbages or with the wolf, unless the farmer is also present. b Draw a bipartite graph to represent the possible river crossings. c Find a solution to the problem. 9

a Write the vertex degrees for the graph with this adjacency matrix.

b Use Ore’s theorem to show that the graph is Hamiltonian. c Use Kuratowski’s theorem to show that the graph is non-planar. d Show that the graph has thickness . 10 The complete graph

is drawn on the vertices

but with the arc

missing.

a Use Euler’s relation for this graph to find the number of regions. Regions are bounded by three arcs that between them share three vertices. b How many ways are there to choose vertices from , excluding any triples, with both and ? c Explain why the answers to parts a and b are different.

Checklist of learning and understanding A graph is a set of vertices connected by arcs. A vertex (or node) is shown as a point in the graph. Vertices may be labelled or not. An arc (or edge) is a line or curve with a vertex at each end. Two vertices are directly connected, or adjacent, if there is an arc with these vertices at its ends. An arc that directly connects to itself is called a loop. An indirect connection between two vertices passes through other vertices and involves more than one arc. A simply connected graph is both simple and connected. A graph is connected if it is possible to get from any vertex to any other, directly or indirectly. A graph is simple if there is exactly one arc between any two adjacent vertices and there are no loops. The degree of a vertex is the number of arcs at that vertex (the number of arcs incident on the vertex). For any graph, the sum of the vertex degrees is twice the number of arcs. A consequence of this is that a graph cannot have an odd number of vertices with odd degrees. A simply connected graph with the minimum possible number of arcs is called a tree. A tree on vertices has

arcs.

A subgraph of a graph is formed using some of the arcs of the graph together with the vertices

that these arcs connect and, possibly, some other unconnected vertices. A walk is a connected subgraph consisting of a set of arcs where the end vertex of one arc is the start vertex of the next. A trail is a walk in which no arcs are repeated. A path is a trail in which no vertex is repeated. A cycle is a closed path (a path with an extra arc that joins the end vertex back to the start vertex). A route is a general term used to mean any of the aforementioned terms. A simply connected graph with the maximum possible number of arcs is called a complete graph. The complete graph with vertices is denoted by

and has

arcs.

The vertices of a bipartite graph can be partitioned into two sets so that every arc joins a vertex from one of these sets to a vertex in the other set. No arc connects two vertices that are in the same set. A simply connected bipartite graph with the maximum possible number of arcs is called a complete bipartite graph. The complete bipartite graph with vertices in one set and vertices in the other set is denoted by

and has

arcs.

An Eulerian graph has no odd vertex degrees. Eulerian graphs are traversable (with the same start and finish point). A semi-Eulerian graph has exactly odd vertex degrees. Semi-Eulerian graphs are semi-traversable (traversable with different start and finish points). A Hamiltonian graph contains a cycle that passes through every vertex (exactly once, apart from the start and finish being the same). Usually there will be arcs in the graph that are not used in the cycle. Ore’s theorem says that, for a simply connected graph, , with the vertex degrees

vertices, if the sum of

for every pair of non-adjacent vertices, then is Hamiltonian.

Two graphs are isomorphic if they have the same structure. The degree sequence of a graph is a list of the vertex degrees, written in increasing order. A graph with directed arcs is called a digraph. The in-degree is the number of arcs that come in at the vertex and the out-degree is the number of arcs that come out of the vertex. A planar graph is any graph that can be drawn with no arcs crossing (can be drawn as one layer). Subdivision: inserting a vertex of degree into an arc. Contraction: removing an arc from a graph and merging the two vertices that it previously joined. Kuratowski’s theorem says that a necessary and sufficient condition for a finite graph to be planar is that it does not contain a subgraph that is a subdivision of

or

.

The thickness of a graph is the minimum number of planar graphs into which the arcs can be partitioned. Euler’s relation says that for any planar graph

.

An adjacency matrix shows the number of arcs that directly join pairs of vertices. In the adjacency matrix for a digraph, the rows show ‘from’ the vertices and the columns show ‘to’ the vertices. A network is a weighted graph. This means that the arcs of the graph have numerical values (weights) attached to them. A simple network can be represented using a weighted matrix, showing the weight of each arc

and a blank, – or

for vertices that are not adjacent.

Mixed practice 2 1

A graph is drawn with vertices labelled their labels is a multiple of .

and . Arcs connect two vertices if the sum of

a Draw this graph. b List all the cycles in this graph. 2

By considering the number of arcs, show that there is only one simply connected graph that connects vertices using arcs.

3

Explain why a graph with degree sequence

4

A graph is described by the adjacency matrix:

is not simply connected.

a Find a subset of the vertices that form a subgraph that is b What can you conclude from this about the original graph? 5

Two of the following graphs are isomorphic.

.

a Which two graphs are isomorphic? b Show that these two graphs are isomorphic. c Show that each of the other two graphs is not isomorphic to any of the other graphs. 6

a A simply connected graph is drawn with vertices and arcs. i What is the sum of the vertex degrees? ii Explain why if the graph has two vertices of degree it cannot have any vertices of degree . iii Explain why the graph cannot have three vertices of degree . b Draw an example of a simply connected graph with vertices and arcs in which one of the vertices has degree and all the vertex degrees are odd numbers. c Draw an example of a simply connected graph with vertices and arcs that is also Eulerian. © OCR, AS GCE Decision Mathematics 1, Paper 4736, January 2007

7

A simply connected Eulerian graph is drawn that has exactly vertices and

arcs.

a Write down the minimum possible vertex degree. b What is the maximum number of vertices that can have this minimum degree? c What is the maximum number of vertices of degree that the graph could have? 8

Three-dimensional noughts and crosses is played using a cube of cells. Label the cells , where represent the coordinates of the cell. A graph is constructed where the vertices represent the cells and arcs join two cells if those cells are not in the same straight line of three cells. a Which cells are directly connected to

?

b Show that the graph is Eulerian. c Show that the graph is connected. 9

A graph has the degree sequence

.

a Explain why the graph must be Eulerian. b Show that the graph need not be connected. c How many arcs does the graph have? d Draw two different connected graphs that have this degree sequence and have exactly arcs with no loops. e What is the greatest value of for which it is possible to draw a connected graph with the degree sequence with no loops?

10 A graph has the following adjacency matrix.

a Write a Hamiltonian cycle for this graph. b Show that Ore’s theorem is inconclusive for this graph. c Use Kuratowski’s theorem to show that the graph is non-planar. d Show that the graph has thickness .

3 Algorithms In this chapter you will learn how to: use an algorithmic approach trace through an algorithm measure efficiency and complexity interpret the order of an algorithm apply the sorting algorithms given in the formula booklet pack items into bins efficiently.

Before you start… GCSE Mathematics



You should be able to round values. You should be able to use a calculator efficiently.

1 Start with the value

and use the Ans key or

the memory of your calculator to repeatedly square root. Record the first four square roots as decimals, to decimal places.

Section 1: Understanding algorithms Definition of an algorithm An algorithm is a step-by-step process or set of rules to be followed in calculations or other problemsolving situations. This could be a recipe used in cooking, a knitting pattern, a computer program or a rule used to solve a problem in mathematics. For example, the quadratic formula is an algorithm.

Tip The word algorithm comes from the Latin algorismus, named after Al-Khwarimi, a ninth-century Persian mathematician and poet. An algorithm must solve the problem, needs an input and an output, must be deterministic and must be finite, as shown in Key point 3.1.

Key point 3.1 An algorithm must solve the problem, needs an input and an output, must be deterministic and must be finite. The input may be a numerical value, list, network or other mathematical object, or it may just be a command to start (this may happen by default). The output may be a numerical value, list, network or other mathematical object, or it may just be a statement that the algorithm has finished (this may happen by default). Deterministic means that, for a given input, the output has the same value each time that input is used. Finite means that the process is completed in a finite amount of time.

WORKED EXAMPLE 3.1

The quadratic formula can be presented as: To find the solution of

[

First work out the value of

[the discriminant]

If

, work out

and

real,

]

[the roots]

Otherwise the equation has no (real) roots.

Show that this is an algorithm. The input is the numerical values of the coefficients and . The output is either the numerical values of and or a statement that there

Check that the step-by-step process satisfies the requirements in Key point 3.1.

and

could be the same.

A ‘STOP’ command may be used to indicate that the process has reached its end.

are no roots. is the same.

The output does not depend on any variable such as the time of day when the formula is used. It is assumed that the process is carried out accurately and that human error does not need to be considered.

The algorithm involves a

Without the ‘otherwise’ the process would have failed to finish properly.

For a given

the output

decision (‘if … then … otherwise’) but no loops. WORKED EXAMPLE 3.2

An ancient algorithm for finding square roots is Heron’s algorithm (named after Heron of Alexandria AD –AD ). This uses a sequence of rectangles, with area , that become closer and closer to squares. To find the square root of : Start with any guess, .

The guess need not be good; you could use .

Work out the value of

.

and are the sides of a rectangle.

If is ‘close’ to STOP and display the value of .

‘Close’ might be, for example, when .

Otherwise the value of becomes the new and you is between and , and go back to the line with the (*). and . So is closer to . Use Heron’s algorithm to find when and are within

,

and

, using

is between

as the initial guess and stopping

of one another. A table is a useful way to show the changes to the variables when working through an algorithm.



Answer:

(to decimal places) Heron’s algorithm is an iterative method because it improves with each attempt and gets closer and closer to the root.



Answer:

(to decimal places) The answer in this case is not (yet). The solutions are the correct values for the roots when rounded to decimal places.



Answer:

(to decimal places)

Processes that loop back on themselves are called recursive processes. With recursive processes, care must be taken to ensure that the process does not get ‘stuck’.

A stopping condition is used to test whether a process should be stopped. In Heron’s algorithm, a stopping condition (STOP when algorithm was finite.

) was used to ensure that the

A stopping condition might involve a counter. A counter is usually set to start at and increases by each time the process loops back on itself. The stopping condition will stop the process when the counter reaches some chosen value.

Practical limitations An algorithm should find the best solution (optimal solution) to a problem. Heuristic methods find good solutions quickly or easily, but the solutions are not guaranteed to be optimal (although they might be).

Tip The term heuristic is taken from the Greek for ‘I find’. If an algorithm involves a lot of work or takes a long time to reach an answer, then a heuristic method might be more practical. Greedy methods make decisions using the choice that seems best at that moment, without regard to the bigger picture, in the hope that this will lead to the optimal solution. Greedy methods might give algorithms but more often give heuristics. An ad hoc method is an ‘impromptu’ strategy that is ‘not planned beforehand’ but may be unique to a particular problem, rather than being a general strategy. The problem with ad hoc methods is that they usually work only for small-scale problems, whereas algorithmic methods are not limited to small-scale problems.

Tip Algorithms can often seem unnecessarily ‘heavy-handed’ for small-scale problems because they are not designed for small problems, but these need to be used to demonstrate how the algorithm works. This is like testing a computer program with a small case for which the answer is already known so that any glitches can be sorted out.

Working with algorithms An algorithm can be given in words, presented using steps (pseudo-code) or as a flow diagram. WORKED EXAMPLE 3.3

Write the quadratic formula as a flow diagram and in simple pseudo-code. A possible flow diagram is: ← Input, this is the start of the process. ← is the discriminant. ← Decisions are usually shown in diamondshaped boxes.

← Output (print) and stop to show the end of the process.

A possible pseudo-code listing is: • STEP 1 Input the values of , and . • STEP 2 Let • STEP 3 If STEP 6.

STEP 2 and STEP 4 use ‘Let’ statements. A let statement can define the new value of a variable in terms of the current value. In this context, ‘let’ means ‘let the new value of’.

print ‘no real solutions’ and go to

• STEP 4 Let

and

• STEP 5 Print the values of

and

.

• STEP 6 STOP. WORKED EXAMPLE 3.4

An algorithm starts with the values The first step is: Let

and

.

.

a What is the new value of ? The second step is a repeat of the first step. b What is the next value of ? The algorithm starts again with the same initial values but with the first step changed to: Let

, with the second step being a repeat of this new first step.

c What are the first two new values of ? a b c Algorithms may use the functions

and

.

gives the integer part of the number , as shown in Key point 3.2.

Key point 3.2 If is an integer, then If

, then

.

is the largest integer that is less than or equal to .

If

, then ).

is the smallest integer that is greater than or equal to (the negative of

gives the absolute value, or modulus, of , as shown in Key point 3.3.

Key point 3.3 is the positive difference between and . If .

, then

; if

, then

Tip You might have these functions on your calculator. Some calculators use also the same as

for

.

is

.

WORKED EXAMPLE 3.5

a Write down the values of: i ii iii iv v b Write down the values of: i ii iii iv v a

i ii iii



When

,

is the largest integer that is less than or equal to .

When

,

is the negative of

When as

, .

is the same as . When

.

iv v b

i ii

,

is the same

iii iv v The stopping condition in Heron’s algorithm asks if is close to . Checking whether and are within of one another can be written as: is The function can be used to find the remainders when a number is divided by some constant or to extract digits from a number. WORKED EXAMPLE 3.6

What are the values of the following expressions when

a b c d e a b c d e You might be asked to trace through an algorithm and interpret what it has achieved and make simple alterations to an algorithm. You might be asked to create an algorithm from a short set of instructions. However, programming skills will not be required. Tracing through an algorithm means working through the algorithm for some specific input values. It is best to record the changes in a table. It is not usually necessary to record steps in which no values change; it is usually necessary to record only the values that have changed. WORKED EXAMPLE 3.7

a Trace through this algorithm when

:

• STEP 1 Let • STEP 2 If

, go to STEP 6.

• STEP 3 Let • STEP 4 Let • STEP 5 Go to STEP 2. • STEP 6 Print the values of and and STOP. b What does the algorithm find, for a positive integer value of ? c What would happen if the value of is not a positive integer? d Use

and

to write a STEP 0 that checks whether is a suitable value.

a

Print STEP 1



STEP 3 STEP 4 STEP 3 STEP 4 STEP 3 STEP 4 STEP 6 b

is the sum of the integers from to . is the sum of the squares of these numbers.

A table can be used to track the changes to the variables. If the step numbers are not recorded, then STEPS 3 and 4 can be merged on a single row. STEP 5 is not recorded because no variables change value.

c If is not an integer or if is a negative integer, then the

There are three cases to consider:

value of will never equal and so the iteration will not stop (so it is not finite and hence is not an algorithm). If

, then the process will stop immediately and print the

values

,



positive but not an integer



negative



.

d STEP 0 If

, display ‘unsuitable ’ and stop.

The words ‘print’, ‘output’ and ‘display’ all mean essentially the same thing in an algorithm.

EXERCISE 3A 1

Write down the values of: a b

2

Why is this process not an algorithm? STEP 1 Input a positive integer . STEP 2 Let STEP 3 If go back to STEP 2. STEP 4 Print . STEP 5 STOP.

3

Trace through the following algorithm using the input

.

STEP 1 Input . STEP 2 Print the value of . STEP 3 Write as a product of primes: STEP 4 Let STEP 5 If STEP 6 Let 4

then STOP. and go back to STEP 2.

For what values of does a

equal each of the following?

i ii iii

b Sketch the following graphs for i ii c For what values of does

?

5

Write Heron’s algorithm (as given in Worked example 3.2) as a flow diagram.

6

The following method has been proposed as a way to solve the equation measured in degrees. Start at

.

Let If

. then STOP and output .

Otherwise replace by

and return to

.

Explain why this is an ad hoc method rather than an algorithm or heuristic. 7

a What does the following algorithm display?

, where is

STEP 1 Let STEP 2 Let STEP 3 Display . STEP 4 Let STEP 5 Let STEP 6 Display .

.

STEP 7 If then go to STEP 9. STEP 8 Go to STEP 2. STEP 9 STOP. b What is the purpose of ? 8

A student claims that this is an algorithm for determining whether a positive integer is prime or not.

a Rewrite the question in the diamond-shaped box, using

or

.

b Describe what happens when the process is applied to the input: i ii iii c Suggest modifications to the process to correct it. 9

a Write down the values that are displayed when the following process is applied with STEP 1 Input . STEP 2 Display the value of . STEP 3 If

then STOP.

STEP 4 If STEP 5 Let

then go to STEP 6. and go to STEP 2.

STEP 6 Let

and go to STEP 2.

b Explain how you know that the process is finite. STEP 5 is replaced by: Let

and go to STEP 2.

c Explain why the new process is not finite. d For what inputs is the new process finite? 10 An algorithm is given below. STEP 1 Input two positive integers, and . STEP 2 Let . STEP 3 Let STEP 4 If STEP 5 Let STEP 6 If STEP 7 Let

then go to STEP 6. then go to STEP 9. and

STEP 8 Go to STEP 3.

.

.

STEP 9 Output the value of and STOP. a Trace through the algorithm using the inputs and

.

b By running the algorithm with other inputs if necessary, suggest how the output value is related to the input values. c Explain how the algorithm achieves this result for any positive integer inputs.

Section 2: Comparing algorithms The order of an algorithm The run-time for an algorithm depends on the number of operations that are carried out, as shown in Key point 3.4.

Key point 3.4 The maximum run-time is the run-time in the worst case and is a function of the size of the problem. The maximum run-time is denoted by , where is the size of the problem (which may be the length of a list or the number of vertices in a network, for example).

Tip The results

and

might be useful.

WORKED EXAMPLE 3.8

a How many additions and how many multiplications are used in evaluating the cubic polynomial when ? b If each multiplication takes seconds and each addition takes seconds, what is the maximum runtime for evaluating a polynomial of degree ? a

multiplications and additions.

multiplications multiplications multiplication

b multiplications and

additions.

The order of an algorithm is given by the dominant term in the run-time for a large-scale problem. This is denoted by . WORKED EXAMPLE 3.9

What is the order of the algorithm used in Worked example 3.8? Quadratic order or

.

is a quadratic function of .

The order of an algorithm can be used to estimate the factor by which the run-time increases when the size of a problem is scaled. WORKED EXAMPLE 3.10

A computer takes

seconds to sort a list of

numbers.

The algorithm used has quadratic order. Estimate how long the computer takes to sort a list of seconds seconds

numbers.

The size of the problem is scaled by a factor of

. The algorithm has quadratic order so the run-time is scaled by approximately .

Efficiency and complexity Key point 3.5 The efficiency of two algorithms that achieve the same end result can be compared by considering the run-time.

WORKED EXAMPLE 3.11

The cubic polynomial

can be written in nested form as

.

Compare the efficiency of the nested form with direct evaluation, as in Worked example 3.8. The nested form involves multiplications and additions, so this must be quicker (more efficient) than direct evaluation.

multiplied by , by , add ,

multiplied multiplied by .

add , minus .

Direct evaluation involves multiplications and additions. In the general case, it is usually easiest to calculate the worst-case run-time, but at A Level the best case or a typical case might also be asked for. WORKED EXAMPLE 3.12

A function is given by The time (in seconds) to evaluate (

, where each of the coefficients and is

or .

for any value of is given by:

the number of multiplications) (

the number of additions)

Find the run-time for: a the worst case b the best case c a typical case a

seconds

multiplication and addition. This is when none of the coefficients are

b

seconds

c

This is when

.

There are nine possible functions. seconds

The cases The cases when The cases

take

seconds.

take seconds. take seconds.

At A Level, the order of an algorithm need not be a power of the size of the problem and could involve logarithms, exponentials and factorials. The hierarchy of orders in terms of efficiency is shown in Key point 3.6.

Key point 3.6 The hierarchy of orders in terms of efficiency: This is given in the formula booklet.

Fast forward You will meet the order of an algorithm again in Chapter 4 when working with network problems.

EXERCISE 3B

EXERCISE 3B 1

An algorithm has order . The time taken to run the algorithm on a problem with seconds. Approximately how long does it take to run the algorithm when ?

2

The worst case run-time of an algorithm for a problem of size is given by is the order of the algorithm?

3

Three different algorithms for packing problems have orders and , where is the number of items to be packed. Which is the most efficient algorithm for large problems?

4

An algorithm has order . The time taken to run the algorithm on three different problems with are seconds, seconds and seconds. Approximately how long does it take to run the algorithm when ?

5

The run-time of the following algorithm, when run on a certain computer, is

is

. What

times the number

of times that STEP 3 is used. STEP 1 Input STEP 2 Let STEP 3 Let STEP 4 If STEP 5 Let STEP 6 Display

then go to STEP 6. and go to STEP 3.

Find the run-time when: a b 6

The run-time of an algorithm, when run on a problem of size , is given by the sum of the positive integers from to that are not multiples of . Find the order of the algorithm.

7

Throughout this question give your answers to significant figures. An algorithm has worst case run-time given by a Calculate the worst case run-time when

. .

The order of the algorithm is b Use the worst case run-time when c Calculate

to estimate the run-time when

.

.

8

An algorithm has order . It takes seconds to run the algorithm when would you expect the algorithm to take when ?

9

The run-time of an algorithm that checks whether a positive integer is prime is given by , where is the largest factor of that is less than or equal to . Find the average run-time for .

. How long

10 An algorithm has order for some positive integer . The time taken to run the algorithm when is seconds and the time taken when is seconds. Find the value of .

Section 3: Sorting and packing problems Strategies for sorting Bubble sort (see Key point 3.7.)

Key point 3.7 Bubble sort algorithm: Start at the left-hand end of the list unless specified otherwise. Compare the first and second values and swap if necessary. Then compare the (new) second value with the third value and swap if necessary. Continue in this way until all values have been considered. Fix the last value and then repeat with the reduced list until either there is a pass in which no swaps occur or the list is reduced to length . Then STOP. This is given in the formula booklet.

WORKED EXAMPLE 3.13

Use bubble sort to sort this list into increasing order: . Record the list at the end of each pass. There is no need to record the individual comparisons and swaps, unless asked to in the question. After st pass:

Compare with and swap, then with with . Fix value .

with

with

After nd pass:

Compare with , (first) with (second) , (second) with and swap, with and swap. Fix the value

After rd pass:

Fix the other . The list is actually sorted but bubble sort does not know this yet.

After th pass:

No swaps so STOP.

Shuttle sort (see Key point 3.8.)

Key point 3.8 Shuttle sort algorithm: Start at the left-hand end of the list unless specified otherwise. Compare the second value with the first and swap if necessary. This completes the first pass. Next, compare the third value with the second and swap if necessary. If a swap happened, then shuttle back to compare the (new) second with the first, as in the first pass. This completes the second pass. Next compare the fourth value with the third and swap if necessary. If a swap happened, then shuttle back to compare the (new) third value with the second, as in the second pass (so if a swap happens shuttle back again). Continue in this way for

passes, where is the length of the list.

This is given in the formula booklet. WORKED EXAMPLE 3.14

WORKED EXAMPLE 3.14

Use shuttle sort to sort this list into decreasing order: . Record the list at the end of each pass. There is no need to record the individual comparisons and swaps, unless asked to in the question. After st pass:

Compare with (no swap).

After nd pass:

Compare with (swap), then compare with (no swap).

Compare (second) with (swap), then compare with (no swap).

After rd pass: After th pass:

is compared with and .

After th pass:

is compared with

and

The number of swaps and/or comparisons can be used to compare different sorting methods for specific lists, as shown in Key point 3.9.

Key point 3.9 Bubble sort and shuttle sort are

, where is the length of the list.

At A Level, the quick sort algorithm may be used, as shown in Key point 3.10 and Key point 3.11. Quick sort for sorting a list into increasing order is given in the formula booklet.

Key point 3.10 Quick sort algorithm: The first value in any sublist will be the pivot, unless specified otherwise. Working from left to right, write down each value that is smaller than the pivot, then the pivot, then work along the list and write down each value that is not smaller than the pivot. This produces two sublists (one of which may be empty) with the pivot between them and completes the pass. Next apply this procedure to each of the sublists from the previous pass, unless they consist of a single entry, to produce further sublists. Continue in this way until no sublist has more than one entry. WORKED EXAMPLE 3.15

Use quick sort to sort this list into increasing order: .



Pivot on .





Fix , then pivot and .









Fix and , then pivot on and . Fix and , no sublist with more than one entry.

Key point 3.11 Quick sort is

in the worst case, where is the length of the list.

Strategies for packing In simple one-dimensional packing problems, a set of weighted items are to be packed into bins with a fixed ‘capacity’. Each bin has the same capacity. The ‘weights’ (and corresponding capacities) might be masses, lengths, volumes, times, etc. The next-fit method involves making a pass along the list, starting at the left-hand end, and packing each item in the next bin that has enough space for it (starting from the bin that has just been used each time). The first-fit method involves making a pass along the list, starting at the left-hand end, and packing each item in the first bin that has enough space for it (starting from the first bin each time). When the first-fit decreasing method is used, the list is sorted into decreasing order and then the sorted list is packed using the first-fit method.

Tip Sorting the list can usually be done ‘by inspection’ without using a sorting algorithm. Packing problems are usually ‘offline’.

Tip An offline problem is one where the whole list of items is known at the start. An online problem is one where the items are released one at a time. The first-fit decreasing algorithm cannot be used with an online problem.

Tip The algorithms are heuristics and may give different packings. It is important to show which item is put into which bin and the order in which they are put into the bins. The full bin method involves trying to fill bins to capacity first and then make bins that are as full as possible.

Tip Full bin is an ad hoc method.

WORKED EXAMPLE 3.16

Seven boxes have masses (in

):

The boxes need to be packed into bins that can hold at most

.

Show the packing that results when each of the previous packing methods is used. Next-fit Bin :

and go in bin but will not fit, so move on to

bin . will not fit, so move to bin .

Bin : Bin : Bin :

Five bins are used.

Bin : First-fit Bin :

Start as before.

Bin :

Each time, the search starts from bin So when the , , , have been packed the fits in bin

Bin :

And so on.

Bin :

Four bins are used.

First-fit decreasing Sort into decreasing order.



Then use first-fit method.

Bin : Bin :

Three bins are used.

Bin : Full bin

There is choice in how the items are combined. Three bins are used.

Bin : Bin : Bin :

At A Level, the packing methods might be extended informally to deal with packing problems in two or three dimensions or problems with additional restrictions. A knapsack problem involves packing some of a set of items, each of which has a mass and a profit (for example), into a fixed number of bins of fixed capacity so that the total profit is maximised. WORKED EXAMPLE 3.17

a Use first-fit decreasing method to pack these items into bins that can hold

.

Item Mass (

)

Profit ( £ ) b Find a packing that maximises the profit when some of the items are packed into two bins that can hold . a

Or swap and . Bin : Bin : Bin :

b For example Bin :



Packing the most profitable items is often a useful way to start. Considering the profit per might also be useful. Full bin method might be appropriate.

£ Bin :

An ad hoc approach could be used.



£ and are not used but either of these would mean either removing or

removing at least two of the other items and, in either case, the profit would decrease.

EXERCISE 3C 1

How many passes does shuttle sort use to sort a list of six numbers into increasing order?

2

Why are at least three bins needed to pack items of masses that can hold up to each?

3

Bubble sort is applied to a list of numbers. After the first pass the list is:







,

,

,

,

into bins



a Is the list being sorted into increasing or decreasing order? Explain how you know. b Carry out the nd pass and count the number of swaps used. 4

The following weights are to be packed into bins that each have capacity units. Explain why at least four bins are needed.

5

A list of numbers is being sorted into increasing order. After the first pass the list is:





a What are the possibilities for the original list if shuttle sort is being used? b What are the possibilities for the original list if bubble sort is being used? 6

A list of items are packed into bins of fixed size. The packing that results for the online problem is given. Bin 1: Bin 2: Bin 3: Which packing method has been used and what is the bin capacity? Explain your reasoning carefully.

7

a Use quick sort to arrange this list into increasing order: b Use quick sort to arrange the same list into decreasing order, using the last value in each sublist as the pivot. c In each case, which elements are the last to be fixed?

8

Assume that the run-time for a bubble sort is ( number of comparisons) (number of swaps), and the run-time for a shuttle sort is (number of comparisons number of swaps), for some positive constant The run-time is the same when bubble sort and shuttle sort are used to arrange the following list into increasing order.













a Find the value of . b Which method is quicker when bubble sort and shuttle sort are used to arrange the list into decreasing order? 9

Jack is packing for a holiday. He can take only two bags, each of which has a limit of One bag has mass and the other has mass . The masses (in ) of the items that he would like to pack are given in the table, together with a ‘value’ that indicates how important Jack rates the item. He will need to leave some of the items behind.

Item Mass Value a Which items should Jack pack into each bag to maximise the value of the items he takes? Jack reviews the values he has given the items and decides that he does not need to take item B. b Show that it is not possible for Jack to pack all the remaining items. Jack decides to change the

bag for a new bag.

c What is the maximum mass of the new bag if Jack can now pack all the remaining items? 10 The following lengths, in metres, need to be cut from pipes of length metres. a Find the smallest value of for which the number of pipes needed using next-fit, first-fit and first-fit decreasing are the same. b Show that for this value of the number of cuts that need to be made is not the same for each method. c The pipes can be bought in lengths of or . The lengths are more expensive than the lengths. Assuming that no errors are made and no length is lost in the cutting process, how many lengths and how many lengths should be bought to minimise the cost?

Explore Recently, computer scientists and biologists have joined forces to study the algorithmic properties of biological processes. By considering how biological systems process information, computer scientists have been able to design algorithms that provide optimal solutions to complex problems. For example, by investigating the activity of neurones in the brain, computational methods known as neural networks were developed, which have been used in work on artificial intelligence and other machine-learning applications. Find out about genetic algorithms and the kinds of problem they can be used to solve.

Checklist of learning and understanding An algorithm is a step-by-step process or set of rules to be followed in calculations or other problem-solving situations. An algorithm must solve the problem, needs an input and an output, must be deterministic and must be finite. The input can be a numerical value, list, network or other mathematical object, or it might just be a command to start (this might happen by default). The output can be a numerical value, list, network or other mathematical object, or it might just be a statement that the algorithm has finished (this might happen by default). Deterministic means that, for a given input, the output has the same value each time that input is used. Finite means that the process is completed in a finite amount of time. Processes that loop back on themselves are called recursive. A stopping condition is used to test whether a process should be stopped.

A stopping condition might involve a counter. A counter is usually set to start at and increase by each time the process loops back on itself. The stopping condition will stop the process when the counter reaches some chosen value. Heuristic methods find good solutions quickly or easily, but the solutions are not guaranteed to be optimal (although they might be). Greedy methods make decisions using the choice that seems best at that moment, without regard to the bigger picture, in the hope that this will lead to the optimal solution. An ad hoc method is an ‘impromptu’ strategy that is ‘not planned beforehand’ but might be unique to a particular problem, rather than being a general strategy. gives the integer part of the number . If is an integer, then

.

If

, then

is the largest integer that is less than or equal to .

If of

, then ).

is the smallest integer that is greater than or equal to (the negative

gives the absolute value, or modulus, of . is the positive difference between and . If

, then

; if

, then

.

The run-time for an algorithm depends on the number of operations that are carried out. The maximum run-time is the run-time in the worst case and is a function of the size of the problem. The order of an algorithm is given by the dominant term in the run-time for a large-scale problem. The efficiency of two algorithms that achieve the same end result can be compared by considering the run-time.



Bubble sort: Start at the left-hand end of the list, unless specified otherwise. Compare the first and second values and swap if necessary. Then compare the (new) second value with the third value and swap if necessary. Continue in this way until all values have been considered. Fix the last value and then repeat with the reduced list until either there is a pass in which no swaps occur or the list is reduced to length , then STOP. Shuttle sort: Start at the left-hand end of the list, unless specified otherwise. Compare the second value with the first and swap if necessary. This completes the first pass. Next compare the third value with the second and swap if necessary. If a swap happened, shuttle back to compare the (new) second with the first, as in the first pass. This completes the second pass. Next compare the fourth value with the third and swap if necessary. If a swap happened, shuttle back to compare the (new) third value with the second, as in the second pass (so if a swap happens shuttle back again). Continue in this way for Bubble sort and shuttle sort are

passes, where is the length of the list. , where is the length of the list.

Quick sort: The first value in any sublist will be the pivot, unless specified otherwise. Working from left to right, write down each value that is smaller than the pivot, then the pivot, then work along the list and write down each value that is not smaller than the pivot.

This produces two sublists (one of which might be empty) with the pivot between them and completes the pass. Next apply this procedure to each of the sublists from the previous pass, unless they consist of a single entry, to produce further sublists. Continue in this way until no sublist has more than one entry. Quick sort is

in the worst case, where is the length of the list.

The next-fit method involves making a pass along the list, starting at the left-hand end, and packing each item in the next bin that has enough space for it (starting from the bin that has just been used each time). The first-fit method involves making a pass along the list, starting at the left-hand end, and packing each item in the first bin that has enough space for it (starting from the first bin each time). When first-fit decreasing is used, the list is sorted into decreasing order and then the sorted list is packed using the first-fit algorithm. The full bin method involves trying to fill bins to capacity first and then make bins that are as full as possible. A knapsack problem involves packing some of a set of items, each of which has a mass and a profit (for example), into a fixed number of bins of fixed capacity so that the total profit is maximised.

Mixed practice 3 1

Use bubble sort to arrange this list in increasing order. Record the list at the end of each pass.





2

An algorithm has order . It takes seconds to run the algorithm when would you expect the algorithm to run when ?

3

Trace through the following algorithm using the input

. How long

.

• STEP 1 Input . • STEP 2 Let

.

• STEP 3 Let

.

• STEP 4 Display . • STEP 5 If

then STOP.

• STEP 6 Let

.

• STEP 7 Go back to STEP 3. 4

A computer takes seconds to pack a list of

items using the first-fit decreasing algorithm,

where the sorting is done using bubble sort. How many items, to the nearest hundred, would you expect the computer to be able to pack in minutes? 5

The following algorithm is designed to find two positive integers for which the sum of their squares is a given input. • Line

Input a positive integer

• Line

Let

• Line

Let

• Line

Let

• Line

If

• Line

If

• Line

Add to

• Line

Go back to line

• Line

Print

• Line

, go to line , go to line

and STOP.

Print ‘fail’ and STOP.

a Apply the algorithm to the input . You only need to record values when they change. Decimal values should be given to decimal places. b Apply the algorithm to the input c Explain why lines

and

.

are needed.

© OCR, AS GCE Decision Mathematics 1, Paper 4736, June 2014 [Abridged] 6

The table shows the average time, lengths, .

seconds, taken to run an algorithm on lists of different

a Show that the order of the algorithm is slower than The run-time is of the form



.

.

b What is the order of the algorithm? c Find appropriate values for the constants 7

and .

Adelina wants to create a program to find the highest common factor and lowest common multiple of two numbers. She has written a program, which she has called miniprog, that has two positive integer inputs ( and ) and gives two outputs ( and ), where is the smaller of and , and is the larger of and minus the smaller. For example, if , then miniprog gives the output below.

and

and

. Adelina’s incomplete program is given

• STEP 1 Input two positive integers and . • STEP 2 Put these values through miniprog. • STEP 3 If

then go to STEP 6.

• STEP 4 • STEP 5 Go to STEP 2. • STEP 6 Let

.

• STEP 7 Print the value of . • STEP 8 • STEP 9 Print the value of

and STOP.

a Write a suitable instruction for STEP 4. b Write a suitable instruction for STEP 8. c Work through the program with the inputs 8

and

.

Some rectangular slabs of toffee are to be packed into shallow trays that measure inches by inches. The table shows the sizes of five slabs given in the form inches by inches, where .

First slab Second slab Third slab Fourth slab Fifth slab Shuttle sort is used to sort the values into decreasing order, then any slabs that have the same values are sorted into decreasing order of . a Record the list of values after each pass through shuttle sort and record the and values at the end of the sorting process.

First-fit is then applied to the sorted list to pack the slabs into the trays. The dimension of length inches is always placed parallel to the -inch edge of a tray and the dimension of length inches parallel to the -inch edge. b Show the resulting packing and show that, even if slabs can be rotated (so and swap for one or more slabs), it is impossible to pack the slabs using fewer trays. The -inch by -inch slab (the fourth slab) is replaced with a -inch by -inch slab. c Show the packing that results when the method described above is applied to the new list. Is it possible to use fewer trays if slabs can be rotated? © OCR, AS GCE Decision Mathematics 1, Paper 2645, June 2003 9

A computer takes seconds, seconds and seconds to run an algorithm with three different lists of length , and seconds to run through a list of length . a What can you deduce about the order of the algorithm? b For what list length would you expect the computer to take

seconds?

10 a Consider all the arrangements of and apply quick sort to each to sort the list into increasing order. Count the number of comparisons used in each case. b What is the average number of comparisons made? c What is the maximum number of comparisons for a list of length ?

4 Network algorithms In this chapter you will learn how to: solve problems requiring the least weight path between two vertices solve problems requiring a minimum spanning tree for a network solve problems requiring a least weight cycle through every vertex in a network find the least weight route around a network that uses every arc.

Before you start… Chapter 3

You should be able to use the order of an algorithm.

1 Algorithm has quadratic order and algorithm has cubic order. It takes seconds to run algorithm on a problem of size and seconds to run algorithm on the same problem. Approximately how long does it take to run each algorithm on a problem of size ?

Section 1: Least weight path between two vertices Finding the shortest or quickest or cheapest route between two places are examples of least weight path problems. These are often referred to as shortest path problems.

Rewind You met paths in Chapter 2. A network can be drawn with vertices representing places and arc weights representing distances, times or costs. The arc weights in such situations will be non-negative. Each problem involves finding a least weight path between two given vertices in a network of undirected arcs with non-negative arc weights. WORKED EXAMPLE 4.1

A simple network is shown. The weights on the arcs represent costs, in £ . Find the cheapest route from to and prove that there is no cheaper route. C

8

A

6 5

2

2

3

6

D

6

E

B 9

F

5

2

H

1

9

, costing £

8

3 G

By inspection.

.

The cheapest route from to is the direct route because any other route from must start with and cost at least £ . Similarly, the cheapest route from to is the direct route because any route from to via costs more.

Showing that this is the cheapest route could be done by considering every possible route. There is no need to travel an arc twice but even so a complete listing of every route would be inefficient, even for a small problem like this.

By considering the cheapest route to each vertex, it becomes apparent that is the cheapest route. to

£ The cheapest route is cheapest route is £

.

. The cost of the

Note the difference between the cheapest route and the cheapest cost.

Common sense cannot be used for even moderate-sized networks so an algorithmic approach is needed. The standard approach is Dijkstra’s algorithm, as shown in Key point 4.1. This formalises the idea of finding the least weight from the start to each vertex, without worrying about the routes taken until the end.

Key point 4.1 Dijkstra’s algorithm: START with a graph, . At each vertex draw a box, the lower area for temporary labels, the upper left-hand area for the order of becoming permanent and the upper right-hand area for

the permanent label.

STEP 1 Make the given start vertex permanent by giving it permanent label and order label . STEP 2 For each vertex that is not permanent and is connected by an arc to the vertex that has just been made permanent (with permanent label ), add the arc weight to . If this is smaller than the best temporary label at the vertex, write this value as the new best temporary label. STEP 3 Choose the vertex that is not yet permanent that has the smallest best temporary label. If there is more than one such vertex, choose any one of them. Make this vertex permanent and assign it the next order label. STEP 4 If every vertex is now permanent, or if the target vertex is permanent, use ‘trace back’ to find the routes or route, then STOP; otherwise return to STEP 2. This is given in the formula booklet.

Tip Dijkstra’s algorithm works out the lengths of the shortest paths from the start vertex to each of the other vertices. Once these values are known, the route(s) of the shortest path(s) can be found. There is no need to record the routes until STEP 4.

Tip Dijkstra’s algorithm works for a network with non-negative arc weights.

WORKED EXAMPLE 4.2

Use Dijkstra’s algorithm to find the cheapest route from to in the network given in Worked example 4.1. STEP 1 Put a box at each vertex. (The box for is at the bottom because there is no space at 1

0

C

8

A

6 5

2

2 9

3 D

6

E

B 6

2 9

Start at with order of labelling least weight (from ).

F

5

and

8 H

1 3 G

STEPS 2 and 3 Working from

.

Temporary labels Least temporary label is Make this permanent.

.

)

1

8

0

9 3

5

6

2

2

3

9

G

STEPS 2 and 3 Working from

C

2

2 9

3

F

5

6 5

6

E

6

2

D

STEPS 2 and 3 Working from 13

C 6

2

2 9

5

3

5

6

2

D 4

6

E 1

9

You need to check all the temporary vertices, not just those that were updated.

13

C

2

2 9

5

3

2

D 4

6

E

6

5

8

G 10

17

STEPS 2 and 3 Working from 13 12

C

2

2 9

3

6

2

D 8

6

E

B

9 5

.

Temporary labels .

F

5

6

8

.

Make this permanent.

8

8

4

Least temporary label is H

3

8

0

5

.

14 10

3

5

.

No update at . 8

1

9

8

Temporary label

F

5

B

5

Tip

STEPS 2 and 3 Working from

6

5

2

Make this permanent.

G

8

8

.

3

8

0

A

Least temporary label is H

14 10

3

2

and are already permanent. 8

8

8

.

Temporary labels

F

5

B

5

Make either of these permanent.

G

8

8

A

Least temporary labels are and . H

3

8

0

2

.

14

3

5

No update at because 8

1

9

8

A

.

Temporary labels

B

5

1

H

1

8

8 5

1

8

8

0 A

1

6

E

D

3 1

2

2

B

5

F

5

6 5

2

C

8

A

6

8 H

1 3

11 11

Least temporary label is

.

Make this permanent. STEP 4 Trace back from

:

G 10

14 10

17 12

Trace back from

: ,

etc.

Route Weight

Trace back from

: , etc.

All the working would be shown on one diagram, not six separate diagrams.



Tip For a small-scale problem, the least weight route might be obvious, so working needs to be shown as evidence that the algorithm has been used, rather than a strategy that could not be scaled up to a realistic-sized problem.

Tip The weights will be non-negative, as shown in Worked example 4.2, but need not be integervalued, unless this is given in the question.

Key point 4.2 Dijkstra’s algorithm is

, where is the number of vertices.

Rewind You met the order of an algorithm in Chapter 3.

Tip There are other algorithms for finding least weight paths, some of which are more efficient than Dijkstra’s algorithm. These are not required here.

EXERCISE 4A 1

Part of a network is shown. Dijkstra’s algorithm is being used to find least weight routes from . Vertex has just been made a permanent label. Update the temporary labels and choose the next permanent label. W 4

V

Y

4

4

10

7 5 9

S 3

... 9

2

2

11 X

Z

2

In question 1 there was a temporary label part of the network?

3

A computer using Dijkstra’s algorithm takes seconds to find the least weight path between two vertices in a network with vertices. How long would you expect it to take for a network with vertices?

4

a Draw the network represented by the following distance matrix.

at . What can you deduce from this about the missing

b Use Dijkstra’s algorithm to find the shortest path from to . 5

Use the answer to question 4 to find the length of the shortest path from to that passes through .

6

The table shows the cost, in units of £

, of travelling between five places.

a Without drawing the network, use Dijkstra’s algorithm to find the cheapest route from to . b What is the cost of the cheapest route from to ? The cost of travelling from to is increased to £



.

c Use your answer to part a to find the cost of the cheapest route in this situation. 7

The road distances (in ) between five cities are shown in the table, except that the distance from Cambridge to Exeter is missing. London

Hull

Glasgow

Cambridge Exeter Glasgow Hull Konrad wants to find the shortest route by road from Cambridge to Exeter, travelling via the places in the table. a Which standard network algorithm does Konrad need to use? b Apply this algorithm to find the length of the shortest route from Cambridge to Exeter. According to a website, the shortest distance from Cambridge to Exeter is c Why is the shortest route from part b longer than this? According to another website, the quickest route from Cambridge to Exeter has length

.

d Why is the quickest route longer than the shortest route? 8

Give an example to show that Dijkstra’s algorithm does not work if there is a negative arc weight.

9

a What is the maximum possible number of temporary values that could be recorded when using Dijkstra’s algorithm for a network with five vertices? b What is the maximum number of additions involved? Finding the maximum of values uses

comparisons.

c What is the maximum number of comparisons used when Dijkstra’s algorithm is used for a network with five vertices? d Give the total number of additions in the worst case when Dijkstra’s algorithm is used on a network with vertices.

Section 2: Least weight tree connecting all the vertices A least weight path joining two vertices could pass through every vertex and might be the least weight way of connecting every vertex, but this is not usually the case. A tree connecting all the vertices in a network is called a spanning tree. A least weight tree connecting all the vertices is a minimum spanning tree or minimum connector.

Rewind You met trees in Chapter 2. The arc weights will often be costs and the minimum spanning tree might represent the cheapest way to join the vertices so that it is possible to get from any vertex to any other, directly or indirectly. One way to find a minimum spanning tree is to use Kruskal’s algorithm, as shown in Key point 4.3.

Key point 4.3 Kruskal’s algorithm: START with all the vertices of , but no edges; list the edges in increasing order of weight. STEP 1 Add an edge of of minimum weight in such a way that no cycles are created. STEP 2 If a spanning tree is obtained then STOP; otherwise return to STEP 1. This is given in the formula booklet.

Tip Kruskal’s algorithm starts with the least weight arc and works through the arcs in increasing order of weight. It builds a collection of little trees that are eventually combined to make a single spanning tree.

WORKED EXAMPLE 4.3

Use Kruskal’s algorithm to find a minimum spanning tree for the following network. C

8

A

6 5

2

2

3 D

6

E

B 9

F

5

6

2

8 H

1 3

9

G

F

C A

H

E

B

D

G Start by listing the arcs in order of increasing weight. Where there

are arcs with the same weight they can appear in any order. It is not usually necessary to write out the whole list, but every vertex must be in the list.

F

C

STEP 1 is used repeatedly to add arcs to the graph (working down the list). Each time check that no cycles are created.

A

Add Add

E

B

H

Add Add

D

G

Add

✓ ✓ ✓ ✓ ✓

STEP 1 At this point the next arc in the list is create a cycle . STEP 1 Add

but this would

.

Although every vertex is now included, the two parts are not connected so a spanning tree is not yet formed.

F

C A

H

E

B

G

D ✓ ✓ ✓ ✓ ✓



C

F

Continue until a spanning tree is formed.

A

Delete all remaining arcs and add the weights of the arcs that have been used, to find the total weight of the spanning tree.

B

E

D ✓ ✓ ✓ ✓ ✓





H

G

Total weight

Tip There might be more than one minimum spanning tree. The order in which arcs of equal weight are considered can give different trees. A second way to find a minimum spanning tree is to use Prim’s algorithm, as shown in Key point 4.4.

Key point 4.4 Prim’s algorithm: START with an arbitrary vertex of . STEP 1 Add an edge of minimum weight joining a vertex already included to a vertex not already included. STEP 2 If a spanning tree is obtained, then STOP; otherwise return to STEP 1. This is given in the formula booklet.

Tip Prim’s algorithm builds a tree by growing out from the starting vertex until every vertex is included.

WORKED EXAMPLE 4.4

Use Prim’s algorithm, starting at , to find a minimum spanning tree for the following network. C

8

A

6 5

2

2

3

6

2

D

D

H 3

G

F

E

B

8

1

9

C

A

6

E

B 9

F

5

H

G

STEP 1 Choose

, the least weight arc from

STEP 1 Choose

, the least weight arc from

STEP 1 Choose to

(or

to to

), a least weight arc from

Tip The arc can start at any of the vertices already included. Continue in this way until a spanning tree is obtained. Add the weights of the arcs that have been used to find the total weight of the spanning tree.

C

A

F

E

B

D

H

G

Total weight

Tip There might be more than one minimum spanning tree. The choice of the starting vertex and the order in which arcs of equal weight are chosen can give different trees. If a computer is being used to solve a problem, then the network is likely to have been given as a distance table, rather than being drawn as a diagram. Prim’s algorithm is easily converted into a form that is suitable for use as a distance network, as shown in Key point 4.5.

Key point 4.5 Prim’s algorithm: START with the table (or matrix) of weights for a connected graph. STEP 1 Cross through the entries in an arbitrary row and mark the corresponding column. STEP 2 Choose a minimum entry from the uncircled entries in the marked column(s). STEP 3 If no such entry exists, STOP; otherwise go to STEP 4. STEP 4 Circle the weight

found in STEP 2, mark column and cross through row .

STEP 5 Return to STEP 2. This is also given in the formula booklet.

Tip STEP 1 columns that are marked correspond to vertices that are in the tree. Entries in rows that are crossed out cannot be chosen, so an arc cannot connect two vertices within the tree. STEP 4 circled entries correspond to arcs that are in the tree. .

is the entry on row and column

WORKED EXAMPLE 4.5

Use Prim’s algorithm, starting at , to find a minimum spanning tree for the network described by the following distance matrix.













  STEP 1 Cross through row and mark column .

arcs

STEP 2 Choose from column .

, the least weight arc, not crossed out,

STEP 4 Record this by circling the entry (and recording in list at side). This entry is . Mark column 2 and cross through (remainder of) row 2.











  STEP 2 Choose , the least weight arc, not crossed out or circled, from columns , .

arcs

STEP 4 Record this by circling the entry (and recording in list at side). This entry is . Mark column and cross through (remainder of) row .  

STEP 2 Choose

.

         

  arcs

Continue in this way until there are no entries that are not circled or crossed out in any of the marked columns.

Add the circled values to find the total weight of the spanning tree.

Total weight

Tip The arcs must be undirected and the weights must be non-negative but need not be integervalued, unless this is given in the question.

Key point 4.6 Kruskal’s algorithm and Prim’s algorithm in the forms used here are

, where is the

number of vertices, and the run-time is measured by counting the number of comparisons in the worst case.

Tip It is possible to improve the order of the algorithms by changing the way that the arcs are searched, but this is not required here.

EXERCISE 4B 1

How many arcs are there in a spanning tree on vertices?

2

There are three different spanning trees connecting the vertices in a labelled complete graph . How many different spanning trees are there connecting the vertices in a labelled complete graph

3

A computer using Prim’s algorithm takes with

4

? seconds to find the minimum spanning tree for a network

vertices. How long would you expect it to take for a network with

vertices?

Find a minimum spanning tree for the network described by the following distance matrix. Give the total weight of this tree.

5

When Prim’s algorithm is used on the network in question 4, the least weight arc cannot be the last to be chosen no matter which vertex is chosen as the start vertex. Explain why.

6

For the network in question 4, suppose that a direct connection is made between and . What is the maximum weight of this arc if it is part of a minimum spanning tree?

7

Five buildings on a university campus are connected by footpaths. It has been suggested that shelters should be installed along some of the footpaths. Only those footpaths with shelters can be used when it is raining. The cost (in £

units) of installing the shelters on each footpath is shown in the table.

The vertices represent the buildings and the arcs represent the footpaths.

The university wants to minimise the money spent on installing shelters. a Which footpaths should have shelters installed for it to be possible to travel between any of the buildings when it is raining? b If an additional £

can be spent on the shelters, on which footpath should it be spent? Explain

your choice. 8

a Explain why a minimum spanning tree must always include a least weight arc. Consider both Kruskal’s algorithm and Prim’s algorithm in your answer. b Give an example of a network in which there is a minimum spanning tree that does not use a certain least weight arc. c Give an example of a network in which the arc with the greatest weight is part of a minimum spanning tree.

9

comparisons are used to find the minimum values of . Prim’s algorithm is used in tabular (matrix) form on a complete network with vertices, where is at least . a How many comparisons are used to choose the first arc? b How many comparisons are used to choose the second arc? c How many comparisons are used to choose the third arc?

10 Why is it not possible to have directed arcs in a minimum spanning tree?

Section 3: Least weight cycle through all the vertices A least weight tree connecting all the vertices might be able to be made into a cycle through all the vertices (a Hamiltonian cycle) by the addition of one arc, but usually the least weight cycle through all the vertices will have greater total weight than the least weight tree. The problem of finding a least weight cycle through all the vertices of an undirected network is called the travelling salesperson problem (TSP). This is one of the most widely studied problems in computational mathematics but no efficient algorithm is known for the general case. The methods that are used are heuristic. Determining whether or not an efficient algorithm exists for the TSP is equivalent to the ‘ versus ’ problem, for which the Clay Mathematics Institute has offered a one million dollar prize. Any Hamiltonian cycle will provide an upper bound for the problem. A sensible way to construct a ‘good’ Hamiltonian cycle is to use the nearest neighbour method, as shown in Key point 4.7.

Tip If the network is not based on a complete graph, then the nearest neighbour method might ‘stall’. This means that the path stops before a Hamiltonian cycle has been achieved.

Key point 4.7 Nearest neighbour method: START at a given vertex of . STEP 1 Find the least weight arc from this vertex to a vertex that has not already been included (or back to the start vertex if every vertex has been included). STEP 2 If no such arc exists, then the method has stalled so STOP; otherwise add this arc to the path. STEP 3 If a cycle has been found, then STOP; otherwise return to STEP 1. This is given in the formula booklet.

WORKED EXAMPLE 4.6

Apply the nearest neighbour method to the following network, starting at , and in turn. C

8

A

6 5

2

2

3

6

D

6

E

B 9

F

5

2

8 H

1 3

9

G

When using the nearest neighbour algorithm, the next arc is chosen from the current vertex to a vertex that has not been used (in contrast to Prim’s algorithm, where it is chosen from any vertex that is already included).

Starting from :

At the least weight arc is

but has already been visited.

The route stalls at because and have already been visited, but not every vertex has been included.

Starting from : stall Starting from :

If you had used the nearest neighbour method from vertex in Worked example 4.6, it would have given the same cycle as that from , but starting Starting from

or would have led to a stall.

Both cycles found using the nearest neighbour algorithm are Hamiltonian cycles, so the least weight cycle has total weight point 4.8.

and

. Since

is smaller than

this is the better upper bound, as shown in Key

Key point 4.8 The smallest of the upper bounds that have been found (least upper bound) is the best of the upper bounds.

Tip The context might permit vertices to be repeated (the salesperson travels through a town that has been visited already). It could be that the nearest neighbour method finds a path through all the vertices but then stalls. In this situation it might be appropriate to repeat some vertices to return to the start. Sometimes short-cuts can be used to improve the upper bound. If vertices were allowed to be repeated in Worked example 4.6, then using .

is shorter than using

A tour is a closed route through every vertex that may pass through vertices more than once. It is useful to try to bound the total weight from below as well as above. If the best lower bound and the best upper bound are the same, then the route that gives the upper bound is an optimal tour. If the upper bound and lower bound are close to one another, then the route that gives the upper bound is either an optimal tour or a very good tour. For a network based on a complete graph, a method for finding a good lower bound (which in some circumstances could be the optimal tour) is shown in Key point 4.9.

Key point 4.9 Lower bound: START with all the vertices and arcs of . STEP 1 Remove a given vertex and all the arcs directly connected to that vertex; find the minimum spanning tree for the resulting reduced network. STEP 2 Add the weight of this minimum connector to the two least weight arcs that have been deleted. This gives a lower bound. This is given in the formula booklet.

Tip If the graph is not based on a complete network, then the method could fail to give a lower bound. An optimal tour uses two arcs to any given vertex, where the total weight of these the sum of the weights of the two least weight arcs from the given vertex. The remainder of the optimal tour is a ‘string’ connecting the other vertices; this must be at least as long as the minimum spanning tree for these vertices. WORKED EXAMPLE 4.7

WORKED EXAMPLE 4.7

Show what happens when the method in Key point 4.9 is applied to the network from Worked example 4.6, when the given vertex is and when the given vertex is . Delete and arcs that are directly connected to (arcs that are incident on ).

Reduced network with deleted. C 6

2

2

3

6

8 H

2

D

6

E

B 9

F

5

1

9

3 G

Minimum spanning tree:

(or

),

Total weight Note that these arcs should be different.

Two least weight arcs from : Lower bound Reduced network with deleted. C

8

A

5

F 8

6 5

6

B 3

H 3

D

9

G

Minimum spanning tree: Total weight Two least weight arcs from : (or or ) Lower bound

Key point 4.10 The largest of the lower bounds that have been found (greatest lower bound) is the best of the lower bounds.

For the problem in Worked examples 4.6 and 4.7, weight of TSP So the tour tour.

of weight

is a good solution; it might or might not be the optimal

EXERCISE 4C 1

and are connected by weighted arcs and Use the nearest neighbour method, starting from . Give the weight of the resulting tour.

2

When nearest neighbour is used on the network in question 1, the arc is included regardless of which vertex is used as the starting vertex. What is the length of a tour that does not use the arc

3

A network has four vertices,

?

, with each vertex connected to each of the others. Ignoring the

direction of travel, how many different cycles are there? 4

a Find the lower bound for TSP for the network described by the following distance matrix, by deleting each of the vertices in turn. b Give the total weight of the best of these lower bounds.

5

a Find the upper bound for travelling salesperson problem for the network in question 4 by using nearest neighbour, starting from each of the vertices in turn. b Give the total weight of the best of these upper bounds.

6

a What is the total weight of the least weight cycle through each vertex of the following network? A

B 9

8

C 6

7

D

b What is the total weight of the least weight closed tour if vertices can be repeated? An additional arc of weight is added, connecting to . c What is the total weight of the least weight cycle through each vertex? d What is the total weight of the least weight closed tour if vertices can be repeated? 7

Five buildings on a university campus are connected by footpaths. It has been suggested that streetlights be installed along some of the footpaths. The cost (in £ units) of installing the streetlights on each footpath is shown in the table. The vertices represent the buildings and the arcs represent the footpaths.

A security guard wants to be able to walk a circuit using only those paths with streetlights, starting and ending at and passing through each of and once. The university wants to minimise the money spent on installing streetlights. a Find a minimum spanning tree for the reduced network formed when all arcs directly joined to are removed. Hence, find a lower bound for the cost for the university.

b Use nearest neighbour to find an upper bound for the cost for the university. 8

A reduced network is formed by removing a certain vertex from a graph. The resulting lower bound for the TSP for the original graph has the same total weight as the best upper bound. What can you deduce about the minimum spanning tree for the reduced network?

9

A graph consists of a weighted tree. a Explain why it is not possible to construct a cycle that passes through every vertex exactly once. A closed route is constructed that passes through every vertex, sometimes more than once. b What is the weight of the closed route?

Section 4: Least weight route using every arc A least weight tour through every vertex might use every arc, but usually there will be arcs that have been missed out.

Tip The problem of finding a least weight route that uses every arc is called the route inspection problem. It is also sometimes known as the Chinese postman problem. Any network formed by weighting an Eulerian graph can be traversed without having to repeat any arcs. The route inspection algorithm works by doubling up on arcs, in the way that gives the least weight possible, so that the graph that is weighted to form the network becomes Eulerian, as shown in.

Key point 4.11 Route inspection problem: START with a list of the odd degree vertices. STEP 1 For each pair of odd nodes, find the connecting path of least weight. STEP 2 Group the odd nodes so that the sum of weights of the connecting paths is minimised. STEP 3 Add this sum to the total weight of the graph, then STOP. This is given in the formula booklet.

WORKED EXAMPLE 4.8

Apply the route inspection algorithm to the following network. C

8

A

6 5

2

2

3 D

6

E

B 9

F

5

6

2 9

8 H

1 3 G

The odd degree vertices are and . The least weight path connecting to is .

Formally, Dijkstra’s algorithm would be used, but (unless the question asks for Dijkstra) the least weight paths can be found using inspection. In this case there is just one pair of odd nodes, so this is the minimum total weight to be added to make all vertices even. Total weight of original graph . This would usually be given in the question.

The minimum weight is . The route uses each arc once and uses and a second time, giving degree , degree and degree .

For example: There is no need to write out a route unless it is asked for.

WORKED EXAMPLE 4.9

Apply the route inspection algorithm to find the weight of the least weight tour that uses every arc in the following network. The sum of the weights in the network is .

14 A

B

6

6

13

D 14 F

15

7

C

12

6 E

The odd degree vertices are and .

Four odd nodes so three pairs of least weight paths (each containing all four odd nodes). Note that the least weight path need not be the direct arc between two vertices. Least weight pairing is

.

Tip If a problem has more than six odd nodes, there will be additional restrictions given that will reduce the number of pairings that need to be considered. The standard route inspection problem starts and finishes at the same vertex. Sometimes a question will indicate that the route need not start and end at the same vertex. In this case, a semi-Eulerian graph is needed, where the route will start at one of the odd degree vertices and finish at the other. WORKED EXAMPLE 4.10

Solve the problem in Worked example 4.9 but allow the route to start and end at different vertices. The odd degree vertices are and . One pair can remain odd, so we just need to find the shortest pairing of the other pair. Route starts and ends at and , repeating

.

EXERCISE 4D 1

Which of the following graphs can be drawn without removing your pen from the paper and without going over an edge twice?

2

The distance matrix for a network is given.

Which vertices have odd vertex degree? 3

What is the least weight path connecting the odd vertices in the network in question 2?

4

Explain why the solution to the route inspection problem for the network in question 2 has total weight .

5

A groundskeeper wants to mark out a design on a pitch using a line-painting machine. The machine is faulty so once it has been switched off it cannot be switched on again. This means that some lines will be painted twice. The design is shown.

The small circle has radius metre, passes through the centre of the larger circle and touches the larger circle. The straight lines are diameters of the larger circle. Each metre uses paint. What is the minimum amount of paint that the groundskeeper needs? 6

litres of

The least weight route that uses every arc at least once is required for the following network. B 11 A

6

D

17

13

E

7 8

C

9

7 12

15

12 G 4

F

When the route inspection algorithm is used, one group of odd nodes is

.

a How many groups of odd nodes are there altogether? b Explain why the total weight of the shortest paths for any group of odd nodes that includes must be greater than . c List the weights and total weight for each group of odd nodes that includes d Explain why

.

must be included in the group with least total weight.

7

For the network in question 6, which arcs would be repeated in a route that covers every arc but starts and ends at different vertices?

8

The total length of the arcs in a network is The vertex degrees are:

metres.

Vertex Degree The lengths, in metres, of the shortest paths between the odd nodes are:

The shortest route that starts at and uses every arc, is required. a Where does the route end? b Use the route inspection algorithm to find the length of the route. 9

The route inspection algorithm is to be used on a network with odd nodes. a Show that

groups of odd nodes would need to be considered.

b Show that the lengths of

shortest paths would need to be calculated.

If it takes seconds to calculate each shortest path and seconds to find the total weight of each group of odd nodes, the time taken for a network with odd nodes will be over minutes. c Calculate the corresponding time for a network with

odd nodes.

Explore Find out about the Königsberg Bridge problem, which was solved by the Swiss mathematician Leonhard Euler (1707–1783). The town of Königsberg, which was in Prussia and is now known as Kalingrad in Russia, had seven bridges connecting the two sides of the River Pregel to two islands in the river. Euler proved that it was impossible to visit all four parts of the town by crossing each bridge only once. Use your knowledge of the route inspection problem to understand Euler’s method.

Checklist of learning and understanding Dijkstra’s algorithm is used to find the route with the least weight between two vertices of a graph. START with a graph, . At each vertex draw a box, the lower area for temporary labels, the upper left-hand area for the order of becoming permanent and the upper right-hand area for the permanent label. STEP 1 Make the given start vertex permanent by giving it permanent label and order label . STEP 2 For each vertex that is not permanent and is connected by an arc to the vertex that has just been made permanent (with permanent label ), add the arc weight to . If this is smaller than the best temporary label at the vertex, write this value as the new best temporary label. STEP 3 Choose the vertex that is not yet permanent that has the smallest best temporary label. If there is more than one such vertex, choose any one of them. Make this vertex permanent and assign it the next order label. STEP 4 If every vertex is now permanent, or if the target vertex is permanent, use ‘trace back’ to find the routes or route, then STOP; otherwise return to STEP 2. Dijkstra’s algorithm is

, where is the number of vertices.

A tree connecting all the vertices in a network is called a spanning tree. A least weight tree connecting all the vertices is a minimum spanning tree or minimum connector. Kruskal’s algorithm builds a minimum spanning tree by adding one edge at a time to a subgraph. At each step, add an edge of of minimum weight in such a way that no cycles are created. START with all the vertices of , but no edges; list the edges in increasing order of weight. STEP 1 Add an edge of of minimum weight in such a way that no cycles are created.

STEP 2 If a spanning tree is obtained, then STOP; otherwise return to STEP 1. Prim’s algorithm (network form) builds a minimum spanning tree by adding one vertex at a time to a subgraph. The vertex added at each step is the one that is nearest to a vertex already included. START with an arbitrary vertex of . STEP 1 Add an edge of minimum weight joining a vertex already included to a vertex not already included. STEP 2 If a spanning tree is obtained, then STOP; otherwise return to STEP 1. Prim’s algorithm (table form) START with the table (or matrix) of weights for a connected graph. STEP 1 Cross through the entries in an arbitrary row and mark the corresponding column. STEP 2 Choose a minimum entry from the uncircled entries in the marked column(s). STEP 3 If no such entry exists, then STOP; otherwise go to STEP 4. STEP 4 Circle the weight

found in STEP 2, mark column and cross through row .

STEP 5 Return to STEP 2. Kruskal’s algorithm and Prim’s algorithm are

, where is the number of vertices.

The nearest neighbour method attempts to build a least weight cycle connecting all the vertices of a graph by finding the least weight arc from a given vertex to a vertex that has not already been included (or back to the start vertex if every vertex has been included) and adding this arc to the path. START at a given vertex of . STEP 1 Find the least weight arc from this vertex to a vertex that has not already been included (or back to the start vertex if every vertex has been included). STEP 2 If no such arc exists, then the method has stalled so STOP; otherwise add this arc to the path. STEP 3 If a cycle has been found, then STOP; otherwise return to STEP 1. A tour is a closed route through every vertex that can pass through vertices more than once. The smallest of the upper bounds that have been found (least upper bound) is the best of the upper bounds. Lower bound START with all the vertices and arcs of . STEP 1 Remove a given vertex and all the arcs directly connected to that vertex; find the minimum spanning tree for the resulting reduced network. STEP 2 Add the weight of this minimum connector to the two least weight arcs that have been deleted. This gives a lower bound. The largest of the lower bounds that have been found (greatest lower bound) is the best of the lower bounds. The route inspection problem finds the shortest route that goes along every edge of a graph and returns to the starting point. START with a list of the odd degree vertices. STEP 1 For each pair of odd nodes, find the connecting path of least weight. STEP 2 Group the odd nodes so that the sum of weights of the connecting paths is minimised. STEP 3 Add this sum to the total weight of the graph, then STOP.

Mixed practice 4 1

a Use Dijkstra’s algorithm to find the least weight path from to Q 7

S

6

P

U

7

8 15

3

5

12 7

7

5

W 4

4

R

in the following network.

V

T

A new arc is added connecting to , but this does not change the least weight path from to . b What is the weight of the new arc? 2

a Find a minimum spanning tree for the network described by the following distance matrix. b State which algorithm you have used. c Give the total weight of the tree.

3

a Apply nearest neighbour to the network in question 2, starting at vertex . b Calculate a lower bound for the TSP using the reduced network formed by removing .

4

A cake decorator wants to mark out a design on a cake using icing. To avoid making a mess when starting and stopping icing, he wants to draw the design as a continuous route. He will achieve this by duplicating some arcs, but wants to minimise the number of vertices that are travelled through more than twice. The design is shown here. A

B

C

D E H

G I

F

J

K

The route needs to start at and finish at . Show that to achieve this every vertex will be travelled through twice. 5

a

i Name an algorithm that can be used to find a minimum connector for a network. ii Demonstrate the use of the algorithm by using it to find a minimum connector for the network in the diagram below.

iii Explain how you know whether or not this minimum connector is unique.

5

A

7

3

B 4

C

6 D

7

8 G

7

The algorithm for finding the minimum connector of a complete network has cubic order as a function of the number of nodes. b What will be the effect on the time taken to run the algorithm if the number of nodes is doubled? © OCR, AS GCE Decision Mathematics 1, Paper 4736, June 2003 6

Yadira is using Dijkstra’s algorithm but gets interrupted. Her vertex labels look like this:









































Yadira has just made a vertex permanent. a Which vertex is this? b What can be deduced about the weights of the arcs that are connected to this vertex? is directly connected to and . c What can be deduced about the weight of each of these arcs? d To which vertices could be directly connected? 7

The cost of travelling by train between eight stations is given in the table. The cost for any cell marked with is and for any cell marked with is

Bodmin Camborne Falmouth Looe Newquay Penzance Saltash

.

Truro a Use the nearest neighbour algorithm, starting from Truro, to find an upper bound for the minimum cost of travelling between the eight stations, starting and finishing at Truro. The upper bounds found by using other stations as the start for nearest neighbour method are:

£

£

£

£

£

£

b Which of these is the best upper bound? c By considering the reduced network formed by removing Truro, find a lower bound for the minimum cost of travelling between the eight stations, starting and finishing at Truro. The lower bounds found by reducing the network by removing other stations are:

£

£

£

d Which of these is the best lower bound? e What can you deduce about the minimum cost of travelling between the eight stations, starting and finishing at Truro? 8

The vertices in the network below represent the junctions between main roads near Ayton The arcs represent the roads and the weights on the arcs represent distances in miles.

6

2 B

7

2

3

F

1.5 D 12

2.5 C

E

8

A

9

4

3

H 7.5

G

a Use Dijkstra’s algorithm to find the shortest path from to . Write down the route of the shortest path from to and give its length in miles. Simon is a highways surveyor. He needs to check that there are no potholes in any of the roads. He will start and end at Ayton. b Which standard network problem does Simon need to solve to find the shortest route that uses every arc? The total weight of all the arcs is

miles.

c Use an appropriate algorithm to find the length of the shortest route that Simon can use. (You can find the lengths of shortest paths between nodes using your answer to part a or by inspection.) Suppose that, instead, Simon wants to find the shortest route that uses every arc, starting from and ending at . d Which arcs does Simon need to travel twice? What is the length of the shortest route that he can use? There is a set of traffic lights at each junction. Simon’s colleague Amber needs to check that all the traffic lights are working correctly. She will start and end at the same junction. e Show that the nearest neighbour method fails on this network if it is started from .

.

f Apply the nearest neighbour method starting from to find an upper bound for the distance that Amber must travel. g Construct a minimum spanning tree by using Prim’s algorithm on the reduced network formed by deleting node and all the arcs that are directly joined to node . Start building your tree at node . Give the order in which nodes are added to your tree and calculate the total weight of your tree. Hence find a lower bound for the distance that Amber must travel. © OCR, AS GCE Decision Mathematics 1, Paper 4736, June 2009 9

A network connects four vertices. The arc weights are shown in the table. The arcs are all undirected apart from

From

The total weight of the least weight connector that enables travel from any of the four vertices to any other is . What is the value of ? 10 A network connects six vertices. The arc weights are shown in the table. The arcs are all undirected apart from and .

From

The total weight of the undirected arcs is

and the total weight of all the arcs is

the weight of the least weight route that uses every arc that: a starts and finishes at b starts at and finishes at

. Find

CROSS-TOPIC REVIEW EXERCISE 1 1

a Use shuttle sort to arrange this list into increasing order. Record the list at the end of each pass. b How many of the following were made during the rd pass? i comparisons ii swaps

2

A paintballing battle takes place in a forest. The tracks through the forest are represented by the arcs in the following network. The vertices correspond to ‘safe zones’ and the arc weights represent travel times between safe zones, in minutes. B

4

2

6

5

A 8

D

F

9

5 7

8

G 10

10

C

E

a Which standard algorithm can be used to find the quickest route from to ? b Use this algorithm to find the quickest route from to . c Find the quickest route from to that travels through every safe zone without repeating any tracks. 3

A graph has degree sequence

.

a Explain why the graph must be semi-Eulerian. b What is the minimum number of arcs that the graph has? c Explain why the graph cannot be simply connected. d Draw two non-isomorphic connected graphs with this degree sequence and with eight arcs. 4

The following algorithm is given. • STEP 1 Input a list of numbers. • STEP 2 Let be the number of values in the list. • STEP 3 Let

.

• STEP 4 If the number in position in the list is less than the number in position , then add these two numbers together and replace the number in position with this sum. • STEP 5 Increase • STEP 6 If

by .

then go to STEP 4.

• STEP 7 Output the list. a Apply the algorithm to the list . Record your working in a table that starts: STEP



List















You need to record values only when they change. Let the number of values in the list that change be used as a measure of the run-time for the list. b Give an example of a list of five numbers with: i the minimum run-time ii the maximum run-time

c

i Write out all the permutations of the four numbers

.

ii Record the output when the algorithm is applied to each of these permutations. iii Find the average run-time for these permutations. 5

people are seated around a circular table. They are split into pairs, each pair holds the ends of a piece of string and the pieces of string are pulled straight. The pairs need to be chosen so that the pieces of string do not cross. For example, when

one possible pairing is

.

A B C

H G F D E

Give the number of ways in which the pairs can be chosen when: a b c 6

Six towns are linked by bus routes. The cost (£ ) of using a direct bus service between pairs of towns is shown in the following cost matrix. A dash means that there is no direct bus service; for example, to travel from to would involve travelling to one of the other towns first.

a Find the cheapest route from to . b

i Construct a minimum spanning tree for the network. ii Give the total weight of the minimum spanning tree. iii Give the cheapest route from to , using arcs only from the minimum spanning tree.

c

i

Apply the nearest neighbour method, starting at .

ii By initially reducing the network by removing vertex , find a lower bound for the least weight Hamiltonian cycle for the original network. d Using only your answers to part c, what can you deduce about the cheapest cost route that travels through each town once, starting and ending at ? 7

A graph has adjacency matrix:

a Apply Ore’s theorem to this graph and state what you can conclude.

b Use Kuratowski’s theorem to show that the graph is planar. c Show that the graph is planar by drawing it with no arcs crossing. 8

A set of six lettered tiles consists of two tiles labelled , two labelled and two labelled . The six tiles are set out in a row; for example: . a How many different arrangements are possible? b Explain carefully why there are

arrangements in which the two s are next to one another.

You are told that there are arrangements that include both the two s next to one another and the two s next to one another, six of which also have the two s next to one another. c Use the inclusion–exclusion principle to find the number of arrangements in which no two consecutive tiles have the same letter. 9

Nine people are seated in a row of chairs. The three empty chairs partition the chairs into four sets. Use the pigeonhole principle to show that there must be three consecutive chairs that are all occupied.

10 The route inspection algorithm is to be used on a network with even nodes and

odd nodes.

a How many shortest paths need to be considered? A computer takes approximately seconds to find each shortest path and, once the shortest paths are all known, a further seconds to pair the shortest paths and solve the route inspection problem. b How long does it take to solve the route inspection problem for a network with ?

and

c It takes about seconds to solve a route inspection problem on a network with a total of vertices. Find the most likely value of for this network. d By considering the ratios of the run-times for successive values of , starting with that the order of the route inspection algorithm: • is not polynomial • is not exponential as a function of .

, show

5 Decision making in project management In this chapter you will learn how to: construct and interpret activity networks carry out critical path analysis calculate and interpret float construct a cascade chart and deal with scheduling restrictions.

Before you start… Chapter 4

You should be able to use networks.

1 Consider the following network. The longest route from to that does not repeat any vertices has weight . Find this route. C

8

A

6 5

D

6

E

B 3



2

2 9

F

5

6

2 9

8 H

1 3 G

Section 1: Critical path analysis A project is made up of activities. Some activities cannot start until others have finished. Project management involves the efficient scheduling of the activities, as shown in Key point 5.1.

Key point 5.1 Scheduling activities in project management: A project is represented by an activity network, in which the activities are represented by directed arcs. The vertices represent events (moments in time between activities). The arc weights represent activity durations.

WORKED EXAMPLE 5.1

Boris is making a cake for a competition. The activities involved are: A:

Put the oven on and let it warm up.

B:

Mix the ingredients for the cake.

C:

Prepare the cake tins.

D:

Put the cake mix into tins and put into the oven.

E:

Mix the filling.

F:

Prepare the icing.

G:

Make the decorations.

H:

Remove the cake from the oven and let it cool.

I:

Put the layers together using filling.

J:

Ice the cake.

K:

Decorate the cake.

• Activity cannot happen until , and have all been completed. • Activity must happen after . • Activity must happen after and . • Activity must happen after and . • Activity

must happen after and .

Show this information as an activity network. D A

There needs to be a single start event and a single finish event.

B C

Any of or can happen first; or, if Boris has helpers, they could happen at the same time.

H

E G

F

I J

K

and could also be done at the start because they have no predecessors. must happen after , which means that it must happen after and , but there is no need to specify this. Only immediate predecessors need to be listed. The arcs must be directed. The activity network includes two dashed arcs called ‘dummy’ activities. These are used to ensure that each activity has a unique start and finish point. Dummies are discussed later.

Tip On a computer, the network would be represented using a distance matrix and arcs would be identified by the vertices that they connect, as shown in Key point 5.2. In Worked example 5.1, , and all connect the same pair of vertices. ‘Dummy’ activities are used so that no two arcs connect the same pair of vertices. The dummy activities are shown as dashed lines.

Key point 5.2 A burst occurs when two activities start from the same event. A merge occurs when two activities end at the same event.

WORKED EXAMPLE 5.2

a Identify the activities that burst for the activity network in Worked example 5.1. b Identify two activities that merge for the activity network in Worked example 5.1. a Activities and all burst from the start event.

Without the dummy activities, , and would merge together. Activities that burst from the same vertex must not also merge together.

b Activities and merge. Activities and merge. Activities and merge. There are two types of dummy activity, as shown in Key point 5.3.

Key point 5.3 The two types of dummy activity: a dummy to enable unique labelling of activities a dummy to preserve precedences. Dummy activities have duration .

WORKED EXAMPLE 5.3

The table shows the activities involved in a project and their immediate predecessors. Activity

Immediate predecessors

Draw an activity network for this precedence table.

W

and start at the same event; a uniqueness dummy is needed so that they do not also finish at the same event.

X

and follow but do not need to have finished.

U

follows but does not need to have finished.

Z V

follows both and , so dummies are used to preserve precedence.

Y

Tip Notice that an arc may be bent around a corner, such as or in the diagram in Worked example 5.3. This does not mean that there is an event at the bend. The events (vertices) will always be indicated. If there are enough workers available, the time needed to complete the project is limited by the longest (maximum weight) route(s) from the start to the finish. A forward pass involves moving through the activity network from the start to the finish and recording the early event time at each vertex. The early event time is the earliest time at which every activity leading into the event can be completed. When activities merge, the greatest of the activity completion times is needed.

Key point 5.4 The minimum project completion time is the early event time for the finish event.

WORKED EXAMPLE 5.4

The table shows the activities involved in a project, their durations and immediate predecessors. Activity

Duration

Immediate

(days)

predecessors

Carry out a forward pass to find the minimum project completion time. 3 V(3) 4

0 W(4)

4

The dummy activities have duration .

X(5) Z(7)

11

When the two dummy activities merge, the early event time is the maximum of and .

Y(6)

The minimum project completion time is days.

When

and merge, the early event time is the maximum of and .

If each activity starts at its earliest possible time, the activities on the longest (maximum weight) route(s)

from the start to the finish are critical. A backward pass involves moving through the activity network from the finish to the start and recording the late event time at each vertex. The late event time is the latest time at which every activity leading from the event can be started without delaying the entire project. Any activity for which the activity duration is the same as the difference between the early time for the event at the beginning of the activity and the late event time for the event at the end of the activity is a critical activity. The early and late event times are usually shown at the vertices, as in the next worked example. WORKED EXAMPLE 5.5

Carry out a backward pass for the activity network in Worked example 5.4 to find the critical activities. 3

4

0

4 4

0 W(4) 4

4

Start at the end, late time

X(5)

V(3)

Z(7)

11 11

Y(6)

Working backwards: at the start of . Min

at the start of .

Min

at the start of .

Min Critical activities:

.

at the start of the project.

The critical activities form a critical path.

The critical activities connect to form a path (or paths) from the start to the finish. Any delay in a critical activity will delay the completion of the project. Delays in non-critical activities might or might not delay the completion of the project. The float (or total float) on an activity is the amount by which the difference between the early event time for the event at the beginning of an activity (earliest start (ES)) and the late event time for the event at the end of the activity (latest finish (LF)) exceeds the activity duration (D), as shown in Key point 5.5.

Key point 5.5 This can be summarised as Float

.

The float represents the amount of time by which the activity can be delayed without delaying the completion of the project. Delays on more than one activity might interfere with one another. Critical activities have zero float. WORKED EXAMPLE 5.6

a Calculate the float for each activity in Worked example 5.5. b The start of activity is delayed by five days. What effect does this have on the minimum project completion time? a

day days (critical) days day

days (critical)

3

4

V(3) 0

X(5)

4 4

0 W(4) 4

4

Z(7)

11 11

Y(6)

Note that activity is not critical. b If is delayed by five days, the minimum project completion time will increase by days to

days.

The float on is three days, so it can be delayed by up to three days with no effect on the minimum completion time. The critical activities are now and .

EXERCISE 5A 1

In the following activity network, which activities are immediate predecessors for activity ? C E

A

G H

D

F

B

2

I

A partial activity network is shown. Values in boxes at vertices are early event times. Weights on arcs are activity durations. Find the missing event time. 23 7

10

18

25

3

An activity has duration hours. In an activity network this activity connects an event with early time and late time to an event with early time and late time .

16 17

27 27

5

How much float does this activity have? 4

The activity network for a project is given. 2 A B

1

D

3 E

5

C 4

The events are numbered

to

.

a Explain why the dummy between

and

is needed.

b Explain why the dummy between

and

is needed.

c List the immediate predecessors for each activity. 5

The table shows the activities involved in the project in question and their durations, in minutes. Activity Duration a Calculate the early event time at each event. b Calculate the late event time at each event. c Which activities are critical?

6

The table shows the activities involved in a project, their durations and immediate predecessors. Activity

Duration

Immediate

(days)

predecessors − −

a Draw an activity network to represent the project. b Calculate the minimum project completion time. 7

The events in an activity network are to . The early and late times for the events are shown in the first table. The activities and their durations, in hours, are shown in the second and third tables. Event Early time Late time Activity Duration Activity Duration a Which activity is a dummy? b What is the minimum project completion time? c Calculate the float on each activity. d Which activities are critical?

8

For the project in question , a delay means that the duration of activities

and

are

increased to hours. a What is the new minimum project completion time? b Which activities are now critical? 9

The activities involved in a project, their durations, in minutes, and immediate predecessors are given in the following table. Activity

Duration

Immediate

(days)

predecessors − −

Activity is not a critical activity. a What is the minimum project completion time? b Which activities are critical? c What values can take?

Explore The first cascade chart was devised in the 1890s by a Polish engineer, Karol Adamiecki. Cascade charts are also known as Gantt charts after the American engineer who, in the early 1900s, devised the version of the chart that is widely used today. The charts were originally drawn by hand, but since the advent of computer technology it has become much easier to draw them and make amendments when necessary during a project. Visit www.gantt.com to investigate the usefulness of Gantt charts and some of the software that can be used to draw them.

Section 2: Scheduling Scheduling involves timetabling activities subject to restrictions. Activities with positive float need not be started immediately. The total float for an activity is made up of independent float and interfering float. Independent float is the amount of time by which an activity can be delayed with no effect on any other activity, as shown in Key points 5.6 and 5.7.

Key point 5.6 The independent float for an activity is given by: [(early event time at finish late event time at start) duration], if this is positive, and by otherwise. This can be summarised as independent float max

Key point 5.7 Interfering float is shared between two or more activities. Interfering float for an activity total float independent float.

WORKED EXAMPLE 5.7

The following activity network represents a project. The boxes at the vertices show the early event times and the late event times, in minutes. D(9)

A(18) 0

24 26

0

33 35

B(8) 8

8

G(13)

24 24

F(11) 46 46

E(22)

C(16)

Calculate the independent and interfering float for each activity. Activity

Total

Independent

Interfering

float

float

float

Activity

Start event Early



Late

Finish event Early

Late

Total float Independent float max Interfering float total independent

Tip In Worked example 5.7, the minutes of interfering float on are shared with , and from are shared with and . A delay on , for example, will reduce the float on and . When dealing with scheduling restrictions, it is useful to also consider the latest time at which an activity can start and the earliest time at which it can finish, as shown in Key points 5.8 and 5.9.

Key point 5.8 The earliest finish time for an activity is the earliest time at which it can finish. Earliest finish time for activity

Key point 5.9 The latest start time for an activity is the latest time at which it can start without affecting the minimum project completion time. Latest start time for activity

Tip It is important that, when calculating float, the early and late event times are used, not the earliest and latest times for the activity.

WORKED EXAMPLE 5.8

For the activity network given in Worked example 5.7: a Calculate the earliest finish time for each activity. b Calculate the latest start time for each activity. a

minutes minutes minutes minutes minutes minutes

Earliest finish time for an activity

.

Activities , and are critical, so the earliest finish time for each of these activities is the same as the event time at the end of the activity.

minutes b

minutes minutes minutes minutes minutes minutes minutes

Latest start time for an activity

.

Activities , and are critical, so the latest start time for each of these activities is the same as the event time at the start of the activity.

Cascade charts are a useful way of visualising the float and activity start/finish times, as shown in Key point 5.10.

Key point 5.10 A cascade chart has a horizontal time axis, a row for the critical activities (or separate rows for each critical activity) and a row for each non-critical activity. Each activity is shown starting at its earliest start time. Float is shown using dashed lines.

Tip For clarity, it might be appropriate to use shading or horizontal lines through the middle of the boxes for the activity or the float.

Tip A cascade chart does not show interference between activities, but these can be seen from the precedences in the activity network.

WORKED EXAMPLE 5.9

Construct a cascade chart for the project given in Worked example 5.7. Here, the critical activities are shown in the bottom row. For reference:

D(9)

A(18) 0 min

24 26

0

33 35

B(8) 8

8

G(13)

24 24

C(16)

F(11) 46 46

E(22)

When using a cascade chart to construct a schedule, the non-critical activities can ‘move’ horizontally within their boxes, provided the activity precedences are taken into account.

Tip Unless a question says otherwise: Once an activity has been started, it must continue without interruption until it has finished. If an activity needs more than one worker, they all start together and all work on the activity without interruption until the activity has finished. Each worker is able to complete any of the activities. All equipment and resources required are available.

WORKED EXAMPLE 5.10

The number of workers required for each activity in the project given in Worked example 5.7 is given in the following table. Activity Workers

a Explain why four workers cannot complete the project in

minutes.

b Construct a schedule to show how the project can be completed in a For completion in minutes, activities and must overlap by at least minutes (earliest finish for and latest start for ), but and together need five workers.

minutes by four workers.

For reference:

D(9)

A(18) 0

24 26

0 B(8) 8 8

Time (mins)

G(13)

24 24

C(16)

b For example:

33 35

F(11) 46 46

E(22)

A schedule may be shown as a diagram or a timetable, for example.

Worker Worker Worker Worker 1

2

3





4

Schedule activities at their earliest start time first, then move them to reduce the number of workers where necessary. Activity uses workers.









EXERCISE 5B 1

An activity has duration hours. The start event for the activity has early time hours and late time hour. The finish event for the activity has early time hours and late time hours. Calculate the interfering float for the activity.

2

An activity has duration days. The start event for the activity has early time days and late time days. The finish event for the activity has early time days and late time days. a Calculate the earliest finish time for the activity. b Calculate the latest start time for the activity.

3

An activity has total float

weeks, of which weeks are independent float and weeks are

interfering float. How long could this activity be delayed without any possibility of it having an effect on the minimum project completion time when: a no other activity is delayed b there are delays on other activities 4

The table shows the activities involved in a project, their durations, in hours, and immediate predecessors.

Activity

Duration

Immediate predecessors − −

Calculate the interfering float for each non-critical activity. 5

The table shows the activities involved in a project, their durations, in days, and immediate predecessors. Activity

Duration

Immediate predecessors − −

Construct a cascade chart for the project. 6

The table shows the activities involved in a project, their durations, in minutes, and immediate predecessors. Activity

Duration

Immediate predecessors − −

Activity is delayed by minutes. Without the minimum project completion time changing, state how many minutes delay there can be on: a activity b activity 7

The table shows the activities involved in a project, their durations, in hours, immediate predecessors and the number of workers needed. Activity

Duration

Immediate

(hours)

predecessors −

Workers



Construct a schedule for three workers to complete the project in the minimum possible time. 8

The table shows the activities involved in a project, their durations, in days, immediate predecessors and the number of workers needed. Activity

Duration

Immediate

(days)

predecessors

Workers

− −

The minimum project completion time is

days.

a By considering the number of worker-hours needed, show that the project cannot be completed by four workers in The critical activities are

days.

and .

b Explain why at least six workers are needed to complete the project in

days.

c Find the minimum time in which four workers can complete the project. d How many days can be saved if five workers are available? 9

For the project presented in Worked example 5.10: a Find the minimum time in which three workers can complete the project. Suppose, instead, that activity could be shared between four workers and would then take only

minutes.

b Find the minimum time in which four workers can complete the project in this case. c How long would it take four workers to complete the project if, when activity is due to start, there is a delay of minutes before it can actually start?

Checklist of learning and understanding

A project is represented by an activity network, in which the activities are represented by directed arcs. The vertices represent events (moments in time between activities). The arc weights represent activity durations. A burst occurs when two activities start from the same event. A merge occurs when two activities end at the same event. There are two types of dummy activity: a dummy to enable unique labelling of activities a dummy to preserve precedences. Dummy activities have duration . A forward pass involves moving through the activity network from the start to the finish and recording the early event time at each vertex. An early event time is the earliest time at which every activity leading into the event can be completed. When activities merge, the greatest of the activity completion times is needed. The minimum project completion time is the early event time for the finish event. A backward pass involves moving through the activity network from the finish to the start and recording the late event time at each vertex. A late event time is the latest time at which every activity leading from the event can be started without delaying the entire project. Any activity for which the activity duration is the same as the difference between the early time for the event at the beginning of the activity and the late event time for the event at the end of the activity is a critical activity. The float (or total float) on an activity is the amount by which the difference between the early time for the event at the beginning of the activity and the late event time for the event at the end of the activity exceeds the activity duration. Total float Independent float is the amount of time by which an activity can be delayed with no effect on any other activity. Independent float = max Interfering float is shared between two or more activities. Interfering float (total)float independent float The earliest finish time for an activity is the earliest time at which it can finish. Earliest finish time for activity The latest start time for an activity is the latest time at which it can start without affecting the minimum project completion time. Latest start time for activity A cascade chart has a horizontal time axis, a row for the critical activities (or separate rows for each critical activity) and a row for each non-critical activity. Each activity is shown starting at its earliest start time. Float is shown using dashed lines.

Mixed practice 5 1

The activity network for a project is shown. The activity durations, in hours, are shown as arc weights. C(3) A(8)

F(6) D(4)

G(4)

B(5) E(5)

a Carry out a forward pass and a backward pass. b Find the minimum project completion time. c List the critical activities. 2

If in question 1 activity takes hours instead of hours: a State the changes there will be in: i the minimum project completion time ii the critical activities b How much extra time could be spent on each non-critical activity before it affects the minimum project completion time?

3

The table lists the activities involved in a project, their durations, in minutes, and their immediate predecessors. Activity

Duration

Immediate predecessors −



a Find the independent and interfering float on each non-critical activity. b Which activity could be delayed by minutes without there being any change to the minimum project completion time? 4

The table shows the activities involved in a project and their predecessors. Activity

Immediate predecessors Explain why two dummy activities are needed when the project is represented as an activity network. 5

In the following table to are events and the entries in the table are activity durations, in hours. A dash means that there is no activity joining the two events. to



from

Activity





















– –



– –







is not critical.

a What can be deduced about the value of ? b What is the interfering float on activity



The independent float on activity

.



is

?

c What can be deduced about the value of ? A delay in the delivery of some of the materials needed means that the start of activity



is delayed. No other activity is affected. d What is the longest delay for the minimum project completion time to remain unchanged? 6

The table shows the activities in a project, their durations, in hours, and immediate predecessors. Activity

Duration

Immediate

(hours)

predecessors − − −

a Represent the project as an activity network. b Carry out a forward pass to find the early event times and a backward pass to find the late event times. c Find the minimum completion time for the project. d List the critical activities. © OCR, A Level GCE Decision Mathematics 2, Paper 4737, June 2009 7

The early and late event times, in hours, for an activity network are given in the first table. The second table shows the activity durations, in hours. Event Early event time Late event time to

– –

from

– –

– –

– –







a Construct a cascade chart for the project. Each activity requires two workers. b Construct a schedule to show how four workers can complete the project in 8

hours.

Tariq wants to advertise his gardening services. The activities involved, their durations (in hours) and immediate predecessors are listed in the table. Activity

A Choose a name for the gardening service.

Duration

Immediate

(hours)

predecessors −



B Think about what the text needs to say.

C Arrange a photo shoot.

D Visit a leaflet designer.

E Design website.

F Get leaflets and business cards printed.

G Identify places to publicise services.

H Arrange to go on local radio.

I

Distribute leaflets.

J

Get name put on van.

a Draw an activity network, using activity on arc, to represent the project. b Carry out a forward pass and a backward pass through the activity network, showing the early event time and the late event time at each vertex of your network. • State the minimum project completion time. • List the critical activities. Tariq does not have time to complete all the activities on his own, so he gets some help from his friend Sally. Sally can help Tariq with any of the activities apart from , and . If Tariq and Sally share an activity, the time it takes is reduced by hour. Sally can also do any of , and on her own. c Describe how Tariq and Sally should share the work so that activity can start hours after the start of the project. d • Show that, if Sally does as much of the work as she can, she will be busy for

hours.

• In this case, for how many hours will Tariq be busy? e • Explain why, if Sally is busy for hours from the start.

hours, she will not be able to finish until more than

• How soon after the start can Sally finish when she is busy for f

Describe how Tariq and Sally can complete the project together in

hours? hours.

© OCR, A Level GCE Decision Mathematics 2 Paper 4737, June 2012

6 Graphical linear programming In this chapter you will learn how to: formulate linear programming problems use slack variables work with constraints solve linear programming problems with two variables graphically and interpret solutions use branch-and-bound for integer programming problems.

Before you start… GCSE

You should be able to solve linear inequalities in two variables, representing the solution set on a graph.

1 Shade on a graph the set of points that satisfy the inequalities:

and GCSE



You should be able to solve simultaneous equations.

simultaneously.

2 Solve the simultaneous equations:

Section 1: Formulating linear programming problems A standard linear programming problem involves maximising or minimising an objective function, as shown in Key point 6.1, that is a linear function of non-negative variables that are constrained by linear inequalities.

Key point 6.1 Formulating a linear programming problem involves: identifying relevant variables, including units when appropriate formulating constraints in these variables writing down an objective function and stating whether it is to be maximised or minimised.

WORKED EXAMPLE 6.1

A car ferry can carry standard cars and large cars. A standard car has length up to metres and mass up to tonnes when fully loaded. A large car has length between metres and metres and mass between and tonnes when fully loaded. Allowing for some space between cars, the ferry company allows metres for each standard car and metres for each large car. The mass of a standard car is assumed to be tonnes and the mass of a large car to be tonnes. The ferry has enough space for tonnes of cars.

metres of cars and can carry up to

The profit for each standard car transported is £ and for each large car is £ . The ferry company wants to know the maximum profit they could make on a single ferry crossing. a Identify appropriate variables for the ferry company’s problem. b Write an objective function in terms of the variables. c Identify the constraints on the values of the variables and represent these algebraically. a

number of standard cars number of large cars

The variables are the number of cars of each type. Defining the variables involves stating what each letter represents and stating appropriate units (in this case ‘number of’).

b Maximise

Maximise the profit (in £ ).

c Subject to:

Total length Total mass

and

are integer valued.

tonnes

Non-negativity (‘trivial’ constraints) restriction to avoid decimal bits of cars.

A linear programming problem in two variables can be solved graphically. The region in which all the constraints of a linear programming problem are satisfied is called the feasible region. It is useful to shade out the unwanted regions of the graph to leave the feasible region as the unshaded region. WORKED EXAMPLE 6.2

Draw a graph of the feasible region for the problem given in Worked example 6.1. passes through and (or use , for example).

Check a point that is not on the line; for example, is on the side of the line where the inequality is satisfied, so shade out the other side. Similarly for the other constraints. The feasible region is the unshaded region.

Tip The constraints might be given as text or in a table. Sometimes the constraints involve ratios rather than specific values. It might be useful to substitute specific values to help plot the boundary line for such a constraint.

WORKED EXAMPLE 6.3

A small café sells two different ‘take-away lunch deals’. Type A costs £ and consists of a filled roll, a

piece of fruit and a bottle of water. Type B costs £ and consists of a sandwich and two pieces of fruit. The café has pieces of fruit available and bottles of water. There is no restriction on the number of rolls or amount of bread, but there is only enough filling for rolls or for sandwiches, or some mixture of rolls and sandwiches. The café owner wants to find the maximum amount that the café can make from selling lunch deals. Set up the problem as a linear programming formulation. number of type A deals sold

Define the variables.

number of type B deals sold Maximise to:

subject

Objective £

.

Pieces of fruit. Bottles of water. Filling. There is enough filling for or for . If the constraint is not obvious, then one way to deal with this is to suppose that each roll uses, say, units of filling, then there are units of filling and each sandwich uses units of filling. This gives . Non-negativity. , are integer-valued.

WORKED EXAMPLE 6.4

A gardener has of garden. She wants to plant vegetables on at least of the garden, and she wants at least twice as big an area for flowers as that for vegetables. The remainder of the garden will be covered in turf.

Preparing the ground for vegetables and planting vegetables costs £ per for flowers and planting flowers costs £ per

; preparing the ground

; and laying turf costs £ per

.

The gardener wants to know what to buy to keep the cost to a minimum. Set up the problem as a linear programming formulation. The total area is turfed is

area planted as vegetables area planted as flowers Minimise

, so the area that is .

Cost in £ . Equivalently, maximise maximise .

subject to:

At least

, or just

of vegetables.

Area of flowers is at least twice the area for vegetables; for example, . At most, all

of the garden is available.

Non-negativity for and . The constraints can be rewritten as equations using slack variables. Slack variables are non-negative variables that are added to the linear function of the variables to make inequality constraints into equations.

Fast forward The reason for wanting equality constraints will become apparent in Chapter 7.

WORKED EXAMPLE 6.5

Use slack variables to rewrite the constraints from Worked example 6.1 as equations. becomes

Slack variables are usually denoted by where these are .

becomes and also The constraints are now

together with four non-negativity constraints:

EXERCISE 6A 1

Graph the feasible region for the constraints:

, etc. or by

, etc.

2

Use slack variables to rewrite the following constraints as equations.

3

Define suitable variables for the following problem. A manufacturing process involves two processes: mixing and finishing. Only one item can be in the process of being mixed at any one time and only one item can be in the process of being finished at any one time. Each type item produced takes process. Each type item produced needs process.

minutes in the mixing process and minutes in the mixing process and

The profit on each type item produced is £

minutes in the finishing minutes in the finishing

and the profit on each type item produced is £

.

The manufacturer wants to maximise the daily profit. 4

Set up the problem from question 3 as a standard linear programming formulation.

5

Set up the following problem as a standard linear programming formulation. Meiying mixes two types of energy drink using dry ingredients, which she has bought in bulk, and water. The table shows the amount of each dry ingredient (in grams) needed for litre of each energy drink and the total amount of each ingredient that is available. Meiying wants to maximise the total amount of energy drink that she makes. Drink Ingredients Xtra Yepp Amount available

6

Calculate the vertices of the feasible region for the problem in question 5.

7

Which of the constraints are redundant (i.e. do not contribute to the feasible region) in the formulation for question 5? Show the redundancy algebraically.

8

The constraints of a linear programming problem are:

where is a positive constant. a For what values of is the second constraint redundant? b Find the vertices of the feasible region in terms of .

Section 2: Working with constraints You might be asked to investigate constraints numerically or algebraically. If there are two variables, then the graph of the feasible region is useful. But if there are more than two variables, then an ad hoc approach might be appropriate. WORKED EXAMPLE 6.6

Some students are making pizzas to sell at a charity event. The number of units of pizza dough needed for each size and each type of pizza is shown in the following table. Small Medium Large

Thin crust Thick crust Stuffed crust not available

The number of units of tomato sauce and the number of units of cheese needed for thin or thick crust pizzas of each size are shown. Small Medium Large Tomato sauce Cheese Stuffed crust pizzas use the same amount of tomato sauce as thin or thick crust pizzas of the same size but use twice as much cheese. For their practise run at making the pizzas, the students have sauce and

units of pizza dough,

units of tomato

units of cheese available.

a Formulate constraints on the number of pizzas of each of the eight types that the students can make. b What is the greatest number of complete pizzas of each type that the students could make? c Show that the students do not have enough ingredients to make one pizza of each type. The students want to practise making at least one pizza of each size and at least one pizza with each crust (e.g. small thin crust, medium thick crust and large stuffed crust). d If they start by making a large stuffed crust pizza, find the maximum number of pizzas they can make in total. e If they do not make a large stuffed crust pizza, find the maximum number of pizzas they can make in total. a Let and represent the number of small, medium and large pizzas, respectively; and let represent thin crust, thick crust and stuffed crust, respectively. For example, number of medium stuffed crust pizzas. Dough:

Define variables representing the number of pizzas of each type.

Tomato sauce:

Cheese:

b

Thin crust

Thick crust

Stuffed crust

and

Small Medium Large c One pizza of each type would need

and

units

, etc.

, etc.

of dough, units of tomato sauce and units of cheese. d If the students make a large stuffed crust pizza, they are left with units of dough, units of tomato sauce and units of cheese.

If they make a medium thick crust and small thin crust, they will be left with units of dough, units of tomato sauce and units of cheese. This is the same amount of tomato sauce and cheese as the case already considered but less dough.

If they make a medium thin crust and small thick crust, they will be left with units of dough, units of tomato sauce and units of cheese. The maximum number of pizzas that can be made with these ingredients is small pizzas, giving a total of pizzas. e If the students do not make a large stuffed crust pizza, then they must make a medium stuffed crust pizza. They are then left with units of dough, units of tomato sauce and units of cheese. If they make a large thin crust and small thick crust, they will be left with units of dough, units of tomato sauce and units of cheese. The maximum number of pizzas that can be made with these ingredients is small pizzas, giving a total of pizzas.

EXERCISE 6B

Dough: Tomato sauce: Cheese:

If the students make a large thick crust and small thin crust, they will be left with units of dough, units of tomato sauce and units of cheese. This is the same amount of tomato sauce and cheese as the case already considered but less dough.

EXERCISE 6B 1

The constraints of a linear programming problem are:

and Show that 2

is not possible.

The constraints of a linear programming problem are:

and Use an algebraic method to show that the only solution is 3

.

The portions of toppings on four pizzas on a menu are summarised below. Pizza Beef Chilli Onion Peppers

There are portions of beef, portions of chilli, available.

portions of onion and portions of peppers

a Find the maximum number of pizzas of each type that can be made. Joanne orders an pizza. She needs another pizzas. b What pizzas can be made with the remaining ingredients? 4

The feasible region of a two-variable linear programming problem has vertices and . a Write down each of the non-trivial constraints in the form integers.

, where

The objective for the linear programming problem is of the form maximise .

and are , where

b Give an expression for the value of at each vertex of the feasible region. c For what values of is the vertex at which is maximum not 5

?

For the problem in question 4, what happens to the vertex at which is maximum as varies from to ?

Section 3: Graphical solutions The objective function for a linear programming problem is a straight line of fixed gradient (also called a profit line). As the value of the objective increases, the profit line slides across the feasible region, while keeping its gradient constant. The optimum point is the point where the sliding profit line last touches the feasible region. This will occur at a vertex of the feasible region (or along an edge if both ends of the edge are optimal), as shown in Key point 6.2.

Key point 6.2 To find the optimal value for a linear programming problem, you can either slide a profit line across the feasible region, in the direction of increasing profit, to determine the optimal vertex (or edge) and then calculate the value of the objective at that vertex (or edge), or calculate the value of the objective at every vertex of the feasible region and deduce the optimum value.

WORKED EXAMPLE 6.7

a Use a sliding profit line to find the maximum value of constraints and . b The objective is changed to change?

, where

on the feasible region defined by the . At what value of does the optimal vertex

c The objective is now changed to maximise , and the constraint . What is the optimal value of in this situation? a Choose a point in the feasible region, such as . At this point the value of is .

The feasible region was graphed in the prerequisites at the start of the chapter. In this diagram the feasible region is shown as the shaded region. Graph the line and

The profit lines will be parallel. This is at the point

, where

b The profit line is gradient

with

is changed to

(i.e.

) passing through

.

Do the same for another value of (e.g. through and ). .

, passing

Slide the profit line in the direction of increasing until it just touches the feasible region (which will usually be at a vertex). As increases, the gradient of the profit line will decrease.

.

This line has gradient

so

The optimal profit line will still pass through lies along the edge defined by the boundary

until it .

. For

the optimal vertex is at

When

the whole of the edge from

to

becomes optimal solutions.

. c

The profit line now has gradient

so

, and for

the original problem the optimal vertex is

The optimum is now at

, where

.

.

Changing to will bring that edge of the feasible region down to pass through and .

Tip Although the vertex checking method is usually easier, the sliding profit line method is better when changes are made to the coefficients in the objective or constraints. It can also be useful when the variables are restricted to taking integer values.

WORKED EXAMPLE 6.8

Solve the problem from Worked example 6.1. Maximise

and

subject to:

are integer-valued. The feasible region was graphed in Worked example 6.2. The vertices of the feasible region can be found by solving the equations of the boundary lines simultaneously, using the equation solver on a calculator. For accuracy, exact values (fractions) should be used unless decimals are exact.

The optimum is

at

.

However, the original problem also had the restriction that and are both integervalued. gives

Informally, it is usually good enough to check integervalued feasible points near the optimal vertex.

Tip If the gradient of the profit line is similar to an edge of the feasible region at the optimum vertex, then the optimal integer-valued point need not be near the optimal vertex. When the variables are restricted to being integer-valued, it might be possible to use the feasible region and superimpose a grid of integer points. WORKED EXAMPLE 6.9

Using a grid of integer points, or by considering the maximum feasible value of for each feasible value of , show that the optimal vertex for the problem in Worked example 6.8 is at . The feasible region was graphed in Worked example 6.2.

For to , the upper boundary of the feasible region is . The maximum integer value of for each value, and the corresponding value of , are shown in the following table.

For to , the upper boundary of feasible region is . The maximum integer value of for each value, and the corresponding value of , are shown in the following table.

The value of

is maximised at

The vertices of the feasible region can be found by solving the equations of the boundary lines simultaneously using the equation solver on a calculator. For accuracy, exact values (fractions) should be used unless decimals are exact.

the point

.

Tip A continuous linear programming problem is a problem for which the variables take real values. The solution to a continuous linear programming problem with two variables can be found using a graph of the feasible region, as shown in Key point 6.3. An integer linear programming problem is a linear programming problem for which (some or all of) the variables are restricted to take integer values.

Fast forward Continuous linear programming problems with more than two variables can be solved using the methods covered in Chapter 7.

Key point 6.3 Branch-and-bound refines the solutions to continuous linear programming problems to solve integer linear programming problems (ILP). STEP 1 Start by solving the continuous linear programming problem. If the solution is integer valued, then STOP. STEP 2 Branch on the values of , if the coordinate is not an integer, by splitting the feasible region into three strips (at least one of which may be empty). Do this by introducing boundaries at and with the optimal vertex from the continuous problem lying in the middle strip. STEP 3 Ignore the middle strip and branch the problem into two cases: the first being the problem together with the additional constraint , and the second being the problem together with the additional constraint . If either of these problems has an empty feasible region, then STOP this branch. STEP 4 Solve the continuous linear programming problems from the branching. If either solution is integer valued, then STOP this branch. STEP 5 For each branch that is still in use, branch on the values of and solve the resulting continuous linear programming problem(s). STEP 6 Continue the branching, alternating between and , until either all branches stop or the value of the objective is worse (smaller, for a maximisation) than the best solution already found at which and are both integer-valued. This strategy can also be used for integer linear programming problems with more than two variables by cycling between the variables.

WORKED EXAMPLE 6.10

Use branch-and-bound to solve the problem from Worked example 6.8. Maximise

subject to:

and

are integer-valued. First solve the continuous linear programming problem. For a two-variable problem this can be done graphically. Cutting the feasible region into that part for which gives a trapezium with edges and . This has vertices and . The value of is maximised at . Similarly, when the feasible region is reduced to a triangle with edges and Branching on from gives the two constraints and . Similarly, branching on from gives the two constraints and . Cutting the reduced feasible region with boundaries , , and , into that part for which , gives a rectangle with edges , , and . Cutting it into that part for which gives a trapezium, with edges , , and . Similarly, cutting the reduced feasible region with boundaries , and , into that part for which , gives a trapezium with edges , , and . Cutting it into that part for which gives no region at all, so this sub-problem is infeasible.

Fast forward Alternatively use the methods from Chapter 7.

The best integer-valued solution is .

at

EXERCISE 6C 1

The optimal vertex for a linear programming problem is . The objective is to maximise . Find the maximum value of on the feasible region.

2

The vertices of the feasible region for a linear programming problem are and . The objective is to maximise . Find the maximum value of on the feasible region.

3

The constraints of a linear programming problem are:

Which of the following are feasible points?

4

An integer linear programming problem is:

Maximise

and

subject to:

are integer-valued.

The optimum vertex for the continuous linear programming is , to significant figures. When branch-and-bound is used, what are the resulting linear programming problems after the first branching? 5

Solve the linear programming problem: Maximise

and 6

subject to:

.

Solve the linear programming problem: Maximise

subject to:

and 7

Solve the integer linear programming problem: Maximise

subject to:

and , are integers. 8

Solve the integer linear programming problem: Maximise

and

subject to:

are integers.

Checklist of learning and understanding A standard linear programming problem involves maximising or minimising an objective function that is a linear function of non-negative variables that are constrained by linear inequalities. Formulating a linear programming problem involves: identifying relevant variables, including units when appropriate

formulating constraints in these variables writing down an objective function and stating whether it is to be maximised or minimised. The region in which all the constraints of a linear programming problem are satisfied is called the feasible region. It is useful to shade out the unwanted regions of the graph to leave the feasible region as the unshaded region. The constraints can be rewritten as equations using slack variables. Slack variables are non-negative variables that are added to the linear function of the variables to make inequality constraints into equations. The objective function for a linear programming problem is a straight line of fixed gradient (also called a profit line). As the value of the objective increases, the profit line slides across the feasible region, while keeping its gradient constant. The optimum point is the point where the sliding profit line last touches the feasible region. This will occur at a vertex of the feasible region (or along an edge if both ends of the edge are optimal). To find the optimal value for a linear programming problem, you can either slide a profit line across the feasible region, in the direction of increasing profit, to determine the optimal vertex (or edge) and then calculate the value of the objective at that vertex (or edge), or calculate the value of the objective at every vertex of the feasible region and deduce the optimum value. Branch-and-bound Start by solving the continuous linear programming problem. If the solution is integer valued, then STOP. Branch on the values of , if the coordinate is not an integer, by splitting the feasible region into three strips (at least one of which may be empty). Do this by introducing boundaries at and lying in the middle strip.

with the optimal vertex from the continuous problem

Ignore the middle strip and branch the problem into two cases: the first being the problem together with the additional constraint , and the second being the problem together with the additional constraint If either of these problems has an empty feasible region, then STOP this branch. Solve the continuous linear programming problems from the branching. If either solution is integer-valued, then STOP this branch. For each branch that is still in use, branch on the values of and solve the resulting continuous linear programming problem(s). Continue the branching, alternating between and , until either all branches stop or the value of the objective is worse (smaller, for a maximisation) than the best solution already found at which and are both integer-valued.

Mixed practice 6 1

The vertices of the feasible region of a linear programming problem are Solve the linear programming problem when the objective is: a maximise b maximise Now consider the objective: maximise

.

c For what value of does the optimal vertex change? 2

Use slack variables to rewrite the constraints:

3

Solve the linear programming problem: Maximise

4

subject to:

A baker has enough flour to make loaves or buns. He has plenty of all the other ingredients. The only other restriction is the baker’s time, as he has hours available to prepare the loaves and buns. A loaf takes minutes to prepare and a tray of buns takes minutes. Each loaf gives a profit of pence and each bun gives a profit of pence. The baker makes loaves and buns, where and are non-negative integers. The baker wants to maximise his profit. a Formulate the baker’s problem as a linear programming problem. b Find how many loaves and how many trays of buns the baker should make. c How much profit could the baker make? d Why might the profit be less than this?

5

Mark wants to decorate the walls of his study. The total wall area is . Mark can cover the walls using any combination of three materials: panelling, paint and pinboard. He wants at least

of pinboard and at least

and it will take Mark

minutes to put up

of panelling. Panelling costs £ per

of panelling. Paint costs £ per

and it

will take Mark minutes to paint . Pinboard costs £ per and it will take Mark minutes to put up of pinboard. He has all the equipment that he will need for the decorating jobs. Mark is able to spend up to £ on the materials for the decorating. He wants to know what area should be covered with each material to enable him to complete the whole job in the shortest time possible. Mark models the problem as a linear programming problem with five constraints. His constraints are:

a Identify the meaning of each of the variables b Show how the constraint

and .

was formed.

c Write down an objective function, to be minimised. Mark rewrites the first constraint as

and uses this to eliminate from the

problem. d Rewrite and simplify the objective and the remaining four constraints as functions of and only. e Represent your constraints from part d graphically and identify the feasible region. Your graph should show and values from to only. © OCR, AS GCE Decision Mathematics 1, Paper 4736, January 2008 6

Consider the following linear programming problem. Maximise

subject to:

a Represent the constraints graphically. Shade the regions where the inequalities are not satisfied and hence identify the feasible region. b Calculate the coordinates of the vertices of the feasible region, apart from the origin, and calculate the value of at each vertex. Hence find the optimal values of and and state the maximum value of the objective. c Suppose that, additionally, and must both be integers. Find the maximum feasible value of for every feasible integer value of . Calculate the value of at each of these points and hence find the optimal values of and with this additional restriction. © OCR, A Level GCE Decision Mathematics 2, Paper 4736, June 2013 7

A shop sells three types of party bag. Each type A bag contains a hat, two balloons, three sweets and a joke. Each type B bag contains a balloon, a joke and a puzzle. Each type C bag contains a hat, two sweets and a puzzle. A customer wants to buy, at most, bags and wants the bags to include at least hats, balloons, and puzzles.

a By considering the number of hats and the number of puzzles, show that the customer must buy at least two bags of type C. b Explain why the customer must buy some bags that are not of type C. c Deduce the number of sweets the customer will get, explaining your reasoning carefully. 8

Use branch-and bound to solve the integer linear programming problem: Maximise

and

subject to:

are both integer-valued.

7 The simplex algorithm In this chapter you will learn how to: use a simplex tableau understand the meaning of the terms basic and non-basic in the context of solving linear programming problems understand iterations of the simplex algorithm geometrically and algebraically.

Before you start…



Chapter 6

You should be able to use graphical linear programming.

Chapter 6

You should be able to use slack variables.

1 Plot the feasible region for the constraints:

2 Write the constraints from question 1 using slack variables.

Section 1: Carrying out the simplex algorithm Using a simplex tableau Key point 7.1 The simplex algorithm can be used to solve a linear programming problem in the following form. Maximise a linear function of the variables subject to a set of constraints, each of which is of the form: A linear function of the variables a non-negative constant and each variable is

.

Unlike the graphical method, the number of variables is not restricted to two. The simplex algorithm uses a matrix formulation of the problem in which the objective and the constraints are written as equations in non-negative variables (by adding slack variables) and the coefficients are presented in tabular form (a simplex tableau), as shown in Key points 7.2 and 7.3.

Rewind You used slack variables in Chapter 6 to turn inequality constraints into equations.

Key point 7.2 The objective must be written in the form: Maximise , where

linear function of the variables constant.

And the constraints must be written in the form: linear function of the variables non-negative constant

Tip Linear function of the variables includes the slack variables, as well as the original variables.

Key point 7.3 The standard format for a simplex tableau has a row representing the objective followed by rows for the constraints (the non-trivial constraints). The columns represent the objective followed by the variables and then the slack variables; the final column represents the right-hand side of the equations.

WORKED EXAMPLE 7.1

Represent this linear programming problem as an initial simplex tableau. Maximise

subject to:

Maximise

subject to:

Rewrite the objective in the form: linear function of variables constant. Rewrite each constraint as: linear function of variables non-negative constant. Add slack variables.

Write the coefficients as an initial simplex tabulation.

The simplex algorithm works by carrying out pivoting operations on the tableau, as shown in Key point 7.4. The algorithm is given in the formula booklet. The operations carried out, in particular in STEP 4, are analogous to those used when solving simultaneous equations.

Key point 7.4 The simplex algorithm: START with a tableau in standard format. STEP 1 Choose a column with a negative entry in the objective row (or zero in degenerate cases). STEP 2 The pivot row is the one for which the non-negative value of the entry in the final column divided by the positive value in the pivot column is minimised. The pivot element is the element in the pivot row of the chosen column. STEP 3 Divide all entries in the pivot row by the value of the pivot element. STEP 4 Add to, or subtract from, all other old rows a multiple of the new pivot row, so that the pivot column ends up consisting of s and a single . STEP 5 If the objective row has no negative entries, then STOP; otherwise return to STEP 1. A question will sometimes specify the column to be chosen in STEP 1, but if there is a choice it is usual to choose the column with the most negative entry in the objective row (or if there is more than one such column to choose from among these the one for which the corresponding column appears earliest in the tableau). Similarly in STEP 2, if there is more than one row giving the minimum ratio, choose any one of them. WORKED EXAMPLE 7.2

Carry out STEP 1 and STEP 2 of the simplex algorithm to find a suitable pivot for the tableau from Worked example 7.1. Pivot on the column because it has the most negative value in the objective row.

Compare ratios:

so pivot on the in the third row of the column. You do not need to consider the ratio for the last row because the entry in the -column is not positive.

Tip Always show how you worked out the ratios in STEP 2 and state the pivot.

WORKED EXAMPLE 7.3

Carry out STEP 3 and STEP 4 of the simplex algorithm to perform one iteration of the simplex tableau from Worked example 7.1.

Divide each element in the pivot row by to form the new pivot row with a in the column (pivot column). Then: replace row by row replace row by row replace row by row so that each of these rows has a in the column (pivot column).

Tip To avoid rounding errors, use fractions when the values obtained are not exact decimals.

Terminology A variable that corresponds to a column in the tableau that consists entirely of s and a single is called a basic variable. The other variables are called non-basic variables. An iteration of the simplex tableau consists of making a non-basic variable into a basic variable and making a basic variable into a non-basic variable, as shown in Key point 7.5.

Key point 7.5

To interpret the output of a simplex tableau: The value of each basic variable is found by reading down the column to the and across to the value in the RHS column. The value of each non-basic variable is .

WORKED EXAMPLE 7.4

Interpret the output of the simplex tableau from Worked example 7.3.

The constraint .

is at its limit

and are because the value in the RHS column is . and are because their columns do not consist of s and a single .

If the objective row has no negative entries, then an optimum has been achieved. WORKED EXAMPLE 7.5

Carry out another iteration of the simplex algorithm on the tableau from Worked example 7.3 and interpret the output. Pivot on the column. Compare ratios:

so pivot on the in the fourth row of the column. Divide row by (row is unchanged). Then: replace row by row replace row by row row is unchanged so that each of these rows has a in the column (pivot column).

The value of the objective has increased to The constraints at their limits.

and

are

There is still a negative value in the objective row, so this is not the optimum. WORKED EXAMPLE 7.6

.

WORKED EXAMPLE 7.6

a Find the optimum solution to the linear programming problem from Worked example 7.1. Maximise subject to:

b Investigate the effect of choosing the first pivot from a different column. a The resulting tableau is:

From the tableau in the solution to Worked example 7.4:

The optimum is

when

and . All three constraints are at their limit. and

.

Divide through the pivot row by . Then: replace row by row replace row by row replace row by row

.

The next pivot is column row , as this is the only row with a positive entry in the pivot column. b If the first pivot is chosen from the column, the result of the first iteration is:

The first pivot in Worked example 7.2 could have been chosen from the column instead of the column. The values in the objective row are both negative. The column was chosen in Worked example 7.2 because is a larger negative value than .

Choose the next pivot from the column results in the same tableau as that in Worked example 7.4. Choose the next pivot from the column (remembering that the pivot element must be positive) to give this table.

The next iteration gives the same final tableau as when the first pivot was from the column.

For this problem, this is the only solution and it is achieved after a total of three iterations, regardless of which column is chosen for each of the pivot

choices.

EXERCISE 7A 1

Represent this linear programming problem as an initial simplex tableau. Maximise

subject to:

2

Which element is the pivot choice for the next iteration of this simplex tableau?

3

Does this tableau represent an optimal solution? Explain how you know.

4

What are the values of the variables in this tableau?

5

Which element is the pivot choice for the next iteration of this simplex tableau?

6

Carry out one iteration of the following simplex tableau, using the in column row as the pivot.

7

Use the simplex algorithm to solve the linear programming problem: Maximise

8

subject to:

a Describe what happens when the simplex algorithm is applied to the following initial tableau, choosing the initial pivot from the column.

b By considering the original linear programming problem, interpret the output from the final tableau. 9

Use the simplex algorithm to solve the following linear programming problem. Maximise

subject to:

When the pivot is chosen from the column the resulting tableau is:

a Interpret the output of this tableau. b By referring to STEP 1 of the simplex algorithm, explain what it means to say that a tableau is

degenerate. c Apply the simplex algorithm to the previous tableau and interpret the output. d How do you know that further iterations will not give any new solutions?



Section 2: Interpretation In two dimensions, the edges of the feasible region are straight lines, each of which corresponds to a variable (or slack variable) taking the value . WORKED EXAMPLE 7.7

Consider the linear programming problem: Maximise

subject to:

In the prerequisites at the start of the chapter, you graphed the feasible region for these constraints and wrote them using slack variables. y 6 5x + 3y = 15

4 2

4x + 5y = 20

O

2

4

6

8

x

a Write the equation of each boundary of the feasible region as a variable

.

b How can the vertices be written? a The boundaries are and

, .

These can be written as . b At the vertices, two of

and and are zero.

is the same as

.

is the same as

.

Each edge is a line of the form variable

.

The points where two of and are zero are the points where the edges intersect. These include the vertices of the feasible region, and other intersections that are not in the feasible region.

The vertices of the feasible region are called basic feasible solutions. At each basic feasible solution the non-basic variables have the value . WORKED EXAMPLE 7.8

Write the initial simplex tableau for the problem in Worked example 7.7 and identify the initial basic feasible solution.

The basic variables are

.

The non-basic variables are The initial basic feasible solution is

.

.

Rewind Look back at Key point 7.5 to remind yourself of how to identify basic and non-basic variables.

Choosing a pivot column corresponds to choosing a variable that, when increased, will increase the value of . Sometimes the variable stays as the value and then is unchanged; it will not decrease. In Worked example 7.8, increasing either or would increase the value of . Choosing a pivot from the column corresponds to increasing the value of but keeping

.

Graphically, this is equivalent to moving along the -axis, from the origin, until another vertex of the feasible region is reached. Choosing the pivot row corresponds to identifying which of the other lines (

or

) is met first.

WORKED EXAMPLE 7.9

a Show algebraically where

meets

, and where

meets

.

b Carry out STEP 2 of the simplex algorithm using a pivot from the column. a meets

at the point

.

meets

at the point

.

b Pivot on the column Compare ratios:

so pivot on the in the second row of the column.

Choosing a pivot entry corresponds to moving along an edge from one vertex of the feasible region to an adjacent vertex, in such a way that the value of the objective does not decrease. Performing an iteration is equivalent to rewriting the problem in terms of the variables that are zero at the new basic feasible solution. WORKED EXAMPLE 7.10

a Rewrite the equations

and

in terms of and .

b Choosing the pivot from the column, perform one iteration of the following simplex tableau.

c Describe the effect of this iteration geometrically. a

Write in terms of and . Substitute for in the objective and simplify. Do the same for the other constraint, with as a basic variable and express the equation for in the same form, with as a basic variable.

b

Pivot on the in row of the -column:

has become basic and has become non-basic. c Move along the edge from to ).

(i.e.

Geometrically, the process moves around the edges of the feasible region until a vertex is reached where the objective cannot be increased. A degenerate solution occurs when there are two vertices of the feasible region with the same maximum value of the objective and the process can move between them.

Key point 7.6 In three dimensions, the boundaries of the feasible region are plane surfaces etc., and the process moves along the edges (where two variables are zero) between the vertices (where three variables are zero). A similar process occurs in higher numbers of dimensions for problems involving more than three variables.

Explore In three dimensions, the simplex algorithm involves a feasible region that is a convex polyhedron. The algorithm begins at a starting vertex and moves along edges until it reaches the vertex of the optimum solution. Investigate how a system of linear inequalities in more than three dimensions defines a polytope as a feasible region for a linear programming problem, and discover how the simplex algorithm got its name.

EXERCISE 7B

1

The feasible region with the following constraints is shown.

y (1)

(2)

(3)

x

O

Identify which of the lines

,

and

is:

a b c 2

For the feasible region in question 1, show algebraically where .

3

A linear programming problem is: Maximise

subject to:

Rewrite the problem in terms of 4

and .

a Perform one iteration of the given simplex tableau.

b Describe the effect of this iteration geometrically. 5

a Perform one iteration of the following simplex tableau.

b Describe the effect of this iteration geometrically.

meets each of

,

and

6

The feasible region of a linear programming problem is a tetrahedron with the following vertices.

Find the equations of the boundaries of the feasible region. 7

a Perform two iterations of the given simplex tableau.

b Describe the effect of these iterations geometrically.

Checklist of learning and understanding To solve a linear programming problem in the following form. Maximise a linear function of the variables subject to a set of constraints, each of which is of the form: A linear function of the variables a non-negative constant and each variable is . The objective must be written in the form: Maximise , where

linear function of the variables constant.

And the constraints must be written in the form: linear function of the variables non-negative constant The standard format for a simplex tableau has a row representing the objective followed by rows for the constraints (the non-trivial constraints). The columns represent the objective followed by the variables and then the slack variables. The final column represents the righthand side of the equations. The simplex algorithm is an algebraic method for solving a linear programming problem. A column with a negative entry in the objective row is chosen as the pivot. The pivot row is the one for which the non-negative value of the entry in the final column divided by the positive value in the pivot column is minimised. The pivot element is the element in the pivot row of the chosen column. All entries in the pivot row are divided by the value of the pivot element. Multiples of the new pivot row are added to, or subtracted from, all other old rows so that the pivot column ends up consisting of s and a single . This is analogous to the method used for solving simultaneous equations by elimination. Continue until the objective row has no negative entries.

A variable that corresponds to a column in the tableau that consists entirely of s and a single is called a basic variable. The other variables are called non-basic variables. To interpret the output of a simplex tableau: The value of each basic variable is found by reading down the column to the and across to the value in the RHS column. The value of each non-basic variable is . If the objective row has no negative entries, an optimum has been achieved. The vertices of the feasible region are called basic feasible solutions. At each basic feasible solution the non-basic variables have the value . Choosing a pivot entry corresponds to moving along an edge from one vertex of the feasible region to an adjacent vertex, in such a way that the value of the objective does not decrease. Performing an iteration is equivalent to rewriting the problem in terms of the variables that are zero at the new basic feasible solution. Geometrically, the process moves around the edges of the feasible region until a vertex is reached where the objective cannot be increased. A degenerate solution occurs when there are two vertices of the feasible region with the same maximum value of the objective and the process can move between them. In three dimensions, the boundaries of the feasible region are plane surfaces etc., and the process moves along edges (where two variables are zero) between vertices (where three variables are zero). This is similar in higher numbers of dimensions for problems with more variables.

Mixed practice 7 1

Without doing any further work, what can you deduce from this tableau about the maximum value of ?

2

What are the values of the variables in this tableau?

3

Which entry would be the pivot for the first iteration of the simplex algorithm for this tableau?

4

Write out the linear programming formulation that is represented by this initial simplex tableau.

5

Tammy makes tanning lotions which she sells to beauty salons. She makes three different lotions using the same basic ingredients but in different proportions. These lotions are called amber, bronze and copper. To make one litre of tanning lotion she needs one litre of fluid. This can either be water or water mixed with hempseed oil. One litre of amber lotion uses one litre of water, one litre of bronze lotion uses litres of water and one litre of copper lotion uses litres of water. Any remainder is made up of hempseed oil. Tammy has litres of water and litres of hempseed oil available.

a By defining appropriate variables, show that the constraint on the amount of water used can be written as . b Find a similar constraint on the amount of hempseed oil used. The tanning lotions also use two colourants, DHA and L-Tyrosine, which give further constraints. Tammy wants to maximise her profit, £ . The problem can be represented as a linear programming problem with the initial simplex tableau below. In this tableau, are slack variables.

and

c Use the initial simplex tableau to write down two inequalities to represent the constraints on the amount of each colourant used. d Write down the profit that Tammy makes on each litre of amber lotion that she sells. e Carry out one iteration of the simplex algorithm, choosing a pivot from the column. Show the operations used to calculate each row. After a second iteration of the simplex algorithm, the tableau is as given below.

f Explain how you know that the optimal solution has been achieved. g • How much of each lotion should Tammy make? • What is her maximum profit? • Why might the profit be less than this? h If none of the other availabilities change, what is the least amount of water that Tammy needs to be able to make the amounts of each lotion given in part g? © OCR, AS GCE Decision Mathematics 1, Paper 4736, June 2014 6

Jenny is making three speciality smoothies for a party: fruit salad, ginger zinger and high C. Each litre of fruit salad contains Each litre of ginger zinger contains

calories and has calories and has

of sugar and of sugar and

of vitamin C. of vitamin C.

Each litre of high C contains

calories and has

of sugar and

of vitamin C.

Jenny has enough milk to make litres of fruit salad or litres of ginger zinger or litres of high C. This leads to the constraint in which represents the number of litres of fruit salad, represents the number of litres of ginger zinger and represents the number of litres of high C. Jenny wants there to be no more than calories and no more than of sugar in total in the smoothies that she makes. a Use this information to write down and simplify two more constraints on the values of and , other than that they are non-negative. Jenny wants to maximise the total amount of vitamin C in the smoothies. This gives the following objective. Maximise b • Represent Jenny’s problem as an initial simplex tableau. • Use the simplex algorithm, choosing the first pivot from the column and showing all your working, to find the optimum. • How much of each type of smoothie should Jenny make? c Show that if the first pivot had been chosen from the column, then the optimum would have been achieved in one iteration instead of two. © OCR, AS GCE Decision Mathematics 1, Paper 4736, June 2010 7

a Perform two iterations of the following simplex tableau.

b Describe the effect of these iterations geometrically.

8 Game theory In this chapter you will learn how to: identify a zero-sum game and understand how games that are not zero-sum are represented understand strict dominance and weak dominance find play-safe strategies and what they represent understand what a stable solution means find optimal mixed strategies for games that do not have stable solutions find a Nash equilibrium and what it represents.

Before you start… Chapter 6

You should be able to find graphical solutions to a linear programming problem.

1 Graph the following constraints, with on the vertical axis and on the horizontal axis.

Find the maximum feasible value of . Chapter 7

You should be able to use the simplex algorithm.

2 For the initial tableau below, use the simplex algorithm to find the values of and for which is maximised.



















(You will find that the first few iterations do not increase the value of ) Game theory has applications in gaming, in warfare and in economics. This chapter gives you an introduction to some of the more important mathematical techniques used in some of these applications. The methods that people use to make their decisions can be of interest to psychologists.

Section 1: Simple two-person, simultaneous play games Payoff matrices The games considered are between two players / two teams where they declare their choices (strategies) simultaneously. WORKED EXAMPLE 8.1

For each of the following games, discuss briefly whether it is a two-person, simultaneous play game. a chess b roulette c rock, paper, scissors d football e snap If you are not familiar with any of these games you could look them up. Some of these games have variations that are used in other cultures. a Chess is a two-player game, but players take turns, so it is not simultaneous play. b Roulette is simultaneous play but usually involves several people, each playing against the ‘house’, not against each other. c Rock, paper, scissors is a two-person, simultaneous play game, provided only two people are playing. d Football involves two teams but they do not declare choices. e Snap is simultaneous play but might involve more than two players. With a two-person simultaneous play game, a table can be used to record the amount that each player wins for each combination of strategies. This is called a payoff matrix. The two players need not have the same number of strategies to choose from. A game will usually be played repeatedly and each player aims to maximise the total amount that they win. WORKED EXAMPLE 8.2

Two people play rock, paper, scissors. Each chooses one of rock, paper or scissors and they show their choices at the same time. Rock wins over scissors, scissors wins over paper and paper wins over rock. The winner gets points and the loser gets points. If both show the same choice they get point each. Construct the payoff matrix. Second player rock paper scissors First rock player paper scissors

The rows represent the possible strategies (choices) for one player and the columns represent the possible strategies (choices) for the other player. The entries in the cells are of the form , where is the number of points won by the player on rows and is the number of points won by the player on columns, when that combination of strategies is played.

Many of the games that are considered can be formulated as zero-sum games. A zero-sum game is one in which, for every combination of strategies, the amount that one player wins equals the amount that the other player loses. A game can be converted to a zero-sum game if the total amount won by the two players is the same for every combination of strategies. The payoff matrix for a zero-sum game is usually written showing just the amounts won by the player on rows. The player on columns wins the negatives of the values in the table. WORKED EXAMPLE 8.3

a Describe how the game of rock, paper, scissors from Worked example 8.2 can be converted to a zerosum game. b Write out the payoff matrix for this zero-sum game. a For each combination of cells, the total amount won is points ( ).

or

Second player

or

If each player pays point to play, then the total amount won and lost is .

rock First player

paper scissors

rock paper scissors

b

Second player rock First rock player paper scissors

paper



scissors

For example, if both play scissors, they each pay in point and they each get point back, so the net gain is points each. The payoff matrix shows the number of points won for the player on rows.





In the game of rock, paper, scissors there is no obvious winning strategy and the play comes down to trying to double guess your opponent. In other games, some choices will be better than others. WORKED EXAMPLE 8.4

The payoff matrix for a zero-sum game is shown. Player B

Player A

a Although player A never wins points by playing , explain why this could still be a winning strategy. b Identify a strategy that player A should never choose. Explain your reasoning.

c Is there a strategy that player B should never choose? Explain your reasoning. a If B plays , then A’s best choice is because every other strategy would result in A losing points.

B is likely to choose as they will either win points or score no matter what A chooses.

b A should never play because gives a better score whatever B chooses.

If B chooses

,

,

If B chooses If B chooses

c No, for example: is better than when A plays but worse when A plays . is better than when A plays but worse when A plays

for A but

.

for A but for A but

. .

Remember that player B wins the negative of the values in the table.

is better than when A plays , but worse when A plays Sometimes a row or column is dominated by another, as shown in Key point 8.1.

Key point 8.1 If every entry in a row is greater than the corresponding entry in another row, the first of these rows is said to dominate (or strictly dominate) the second of these rows. The player on rows would never choose a row that is dominated by another. If every entry in a row is greater than or equal to the corresponding entry in another row, and the two rows are not the same, the first of these rows is said to weakly dominate the second of these rows. There is no advantage for the player on rows in choosing a row that is weakly dominated by another. Similarly, one column dominates another when the payoff for the player on columns is better in every row (remembering that in a zero-sum game the player on columns wins the negative of the value in the table), or weakly dominates if they are better or equal (and not all equal). In Worked example 8.4, row dominates row payoff matrix reduced:

. A dominated row (or column) can be removed and the

Player B Player A





Pure strategies For the reduced game from Worked example 8.4, you might have an opinion about which strategy you would choose if you were either player A or player B, but what you choose depends on whether you are an optimist or a pessimist. For example, player A could argue that gives the maximum possible score of (and also the maximum row total), but if B often plays this would be a poor choice for A. A pessimist would usually consider the worst possible outcome and then select their strategy accordingly. The play-safe strategy for either player is the strategy for which the worst possible score is best (the least

worst strategy). There might be more than one play-safe strategy for either player. In a zero-sum game, for the player on rows, the play-safe strategy is the row for which the row minimum is largest (the row maximin) for the player on columns; the play-safe strategy is the column for which the column maximum is smallest (the column minimax). WORKED EXAMPLE 8.5

a Find the play-safe strategies for the zero-sum game with the following payoff matrix. Player B Player A





b What would happen if player A knew that player B would play safe? c What would happen if player B knew that player A would play safe? a

Player B

Row

Find the minimum value in each row (the worst possible outcome for player A when they choose that strategy). The maximum of the row minima (the row maximin) is .

min. Player A

Col.



max. The play-safe strategies for A are and ; the play-safe strategy for B is . b If A knew that B would play safe, then A would play .

The strategies that correspond to the row maximins are the play-safe strategies for player A. The table shows the payoffs for player A. The payoffs for player B are the negatives of the entries in the table. Find the maximum value in each column (the negative of which is the worst possible outcome for player B when they choose that strategy). The minimum of the column maxima (the column minimax) is .

c If B knew that A would play safe, then B would have to guess whether A was going to play or . If A plays , then B would be best playing (but then A would change to ). If A plays , then B would be best playing .

The strategy that corresponds to the column minimax is the play-safe strategy for player B.

Sometimes the payoffs mean that if either player chooses to play safe, then the best option for the other is also to play safe, as shown in Key point 8.2. Such a game is called a stable game.

Key point 8.2 A zero-sum game is stable when the row maximin value equals the column minimax value. If both players play safe, then neither of them will have any incentive to change.

Fast forward If you study surfaces in Further Additional Pure Mathematics, you will recognise that a stable solution is a saddle point (a maximum in one direction and a minimum in the other).

WORKED EXAMPLE 8.6

Which of these games are stable? a

b

c

d

a

Row min.

Col. max. Row maximin

and col. minimax

Therefore, stable game. b

Row min.

Col. max. Row maximin

and col. minimax

Therefore, unstable game. c

Row min.

Col. max. Row maximin

and col. minimax

Therefore, unstable game. d

Row min.

Col. max. Row maximin

and col. minimax

Therefore, unstable game. A Nash equilibrium is a combination of strategies for which neither player would want to change if they know that the other is not going to change, as shown in Key point 8.3. This is a particularly useful concept for a game that is not zero-sum.

Key point 8.3 To find a Nash equilibrium, you first need to identify the cell(s) in each row where the player on columns gets the highest payoff ( value max. in each row). Then identify the cells in each column where the player on rows gets the highest payoff ( value max. in each column). If there are any cells that give a maximum column value for the row and a maximum row value for the column, then these are Nash equilibrium solutions. A game might have multiple Nash equilibrium solutions or it might have none.

WORKED EXAMPLE 8.7

Find Nash equilibrium solutions (if any exist) for each of the following games. a



b



c

   

d

a

  



Best for columns in row Best for columns in row Best for rows in column Best for rows in column Nash equilibrium b



Best for columns in row Best for columns in row Best for rows in column Best for rows in column Best for rows in column No Nash equilibrium. c



Best for columns in row Best for columns in row Best for rows in column Best for rows in column

Nash equilibrium d



Best for columns in row Best for columns in row Best for columns in row Best for rows in column Best for rows in column Best for rows in column and and are both Nash equilibrium solutions.

EXERCISE 8A 1

The matrix shows the payoffs for a game. The entries are of the form the player on rows and is the score for the player on columns. Player B Player A

Explain why this game cannot be converted to a zero-sum game. 2

Show that this zero-sum game is stable.

3

Show that row weakly dominates over row for this game:

4

Show that the zero-sum game below can be reduced using dominance.

, where is the score for

5

Alice and Bob play a card game. Each has three cards. Alice’s cards are labelled , and . Bob’s cards are labelled , and . Alice and Bob each select a card and reveal their choices simultaneously. The player whose card has the larger value scores the value on their card, and the other player scores the difference between the values on the two cards. Write the payoff matrix to show the scores for Alice and Bob for each combination of strategies. Put Alice’s options on rows and Bob’s on columns.

6

Find the play-safe strategy for each player for this game. Sandi Rupi

7

The payoff matrix for a game is: Fionn



Gina











































The game can be converted to a zero-sum game. a Write down the payoff matrix for the zero-sum game, showing the values for Gina only. b Determine whether this game is stable or unstable. c Deduce whether column is dominant over any other column. 8

Find any Nash equilibrium solutions for the following game.

9

The payoff matrix for a zero-sum game is:

Determine any values of for which the game is stable.

Section 2: Mixed strategies For an unstable game the best tactic, over a long run of games, is to use a mixed strategy. A mixed strategy means that the player uses random numbers to choose between the probabilities, playing them with probabilities that are calculated to maximise the minimum expected payoff, as shown in Key point 8.4.

Key point 8.4 To find a mixed strategy for a player in an unstable game when a player has two options: Let the probability of playing the options be and Calculate the expected payoff, in terms of , when the other player uses each of their options. Sketch a graph showing the expected payoff against for The feasible region is the area below all the expected payoff lines for Find the maximum feasible value of the minimum expected payoff by sliding a horizontal profit line up across the feasible region until it reaches the highest point.

Tip Imagine scanning across the graph from to , and for each value of using the minimum expected payoff. This lower boundary on the graph gives the row minimum for each value of , and the highest point on the lower boundary corresponds to the row maximin. The value of where the lower boundary is highest is the optimum choice for the mixed strategy. This value could occur at one of the extremes, or , but more often it will be at a value between these extremes and simultaneous equations can be used to calculate the optimum value of .

WORKED EXAMPLE 8.8

Find the optimal mixed strategy for the player on rows for this zero-sum game.

Choose randomly between the rows so that row is played with probability and row with probability

The game is unstable:

Row min.

Expected payoff for rows when columns plays is: Expected payoff for rows when columns plays is:

Col. max. Row maximin

column minimax

unstable game.

Expected payoff for rows when columns plays is: This is the graph from the start of the chapter but with an extra line , and the region above that line shaded. A sketch graph is sufficient.

E

5 4 3 2 1 O

1

p

Maximum value occurs at highest point: Choose row with probability and row

For example, use single digit random numbers: Let to mean ‘play row ’.

with probability

Let mean ‘play row ’ and ignore

.

Explore The prisoners’ dilemma is a well-known game of strategy in social science. It was developed by RAND Corporation scientists Merrill Flood and Melvin Dresher and was formalised by Albert W. Tucker, a Princeton mathematician. Two suspects have been arrested for a crime and are being interrogated in separate rooms. Each can either confess and implicate the other and so have the charges dropped against them or they can remain silent. Each is better off individually if they confess (i.e. confession is the dominant strategy), but if the other one confesses and the first remains silent, the first will be charged and punished for the crime. If both confess, then they will both receive punishment, so the outcome is worse for both prisoners than when they both keep silent. Find out how the prisoners’ dilemma can help you to understand the balance between cooperation and competition in business, politics and social contexts.

Key point 8.5 To find a mixed strategy for a player in an unstable game when a player has more than two options: Add a constant throughout the payoff matrix to make all the payoffs non-negative. Let the probability of playing the options be Calculate the expected payoff, in terms of options.

when the other player uses each of their

Set up a linear programming problem: maximise subject to and

(or constant that was previously added). expression for expected payoff for each option

Use the simplex algorithm to find the values of

Rewind You used the simplex algorithm in Chapter 7.

Tip

1 The reason for adding a constant is to ensure that the minimum expected payoff, , is nonnegative. 2 The reason for writing the total probability as (instead of ) is so that there is a row in the simplex tableau with non-zero. Without this the value of the objective would never increase. At the optimum, there will be no slack in this constraint, since otherwise can still be increased. 3 In reality, a computer would be used to solve the simplex problem.

WORKED EXAMPLE 8.9

a Set up the initial simplex tableau to find the optimal mixed strategy for the player on rows for this zero-sum game.

b Given that the optimal solution for the player on rows is to play with probability and with probability , calculate the value of the game for the player on rows. c Find the optimal mixed strategy for the player on columns. Add throughout table to make all entries nonnegative.

a

Choose randomly between the rows so that row is played with probability , row with probability and row with probability Add slack variables and set up initial tableau.

Maximise



subject to









































































b The value of the game for the player on rows is , where

and

These are taken from the linear programming formulation. Both inequalities give value of is

So

and the value of the game is

.

. Since the game is zero-sum.

so the max

c The value for the player on columns is

.

Suppose that the player on columns chooses randomly between columns and , playing column with probability . The player on rows will play either or . When is played this gives

The player on columns wins the negatives of the amounts in the table.

Choose with probability and with

If is played, player on columns expects to win

probability .

.

If is played, player on columns expects to win

.

Max. value that is

and

is

.

EXERCISE 8B 1

The payoff matrix for a zero-sum game is:

Player B

Player A

Player A chooses randomly between the rows so that row is played with probability and row with probability Find and simplify an expression for the expected payoff for player A when player B chooses strategy . 2

Sunny and Tom play a zero-sum game. The expected payoffs for Sunny when Tom plays each of his strategies are and . Find the optimal value of

3

A zero-sum game has payoff matrix:

A mixed strategy for the player on rows is to be found by formulating the problem as a linear programming problem. Before the constraints can be formulated, the payoff matrix must be adjusted. Write out a suitable adjusted payoff matrix. 4

The payoff matrix for a zero-sum game is:

Player B



Player A

Player B chooses randomly between the columns so that column is played with probability and column with probability . Find and simplify an expression for the expected payoff for Player B when player A chooses each of strategies and . 5

Ben and Cindy repeatedly play a zero-sum game. The payoff matrix for the game is:

Cindy

Ben

Ben and Cindy both play using their optimal mixed strategy. a Find the optimal mixed strategy for Ben. b How much should Ben expect to win per game, in the long run? c How much should Cindy expect to win per game, in the long run? 6

In a zero-sum game the player on rows chooses between strategies and the player on columns chooses between strategies. The problem of finding the optimal mixed strategy for the player on rows is set up as an initial simplex tableau. How many rows and how many columns does the simplex tableau have?

7

Set up the initial simplex tableau to find the optimal mixed strategy for the player on rows for this zero-sum game.

8

Set up the initial simplex tableau to find the optimal mixed strategy for the player on columns for this zero-sum game.

Checklist of learning and understanding The games considered are between two players / two teams where they declare their choices

simultaneously. With a two-person simultaneous play game a table can be used to record the amount that each player wins for each combination of strategies. This is called a payoff matrix. The two players need not have the same number of strategies to choose from. A game will usually be played repeatedly and each player aims to maximise the total amount that they win. A zero-sum game is one in which, for every combination of strategies, the amount that one player wins equals the amount that the other player loses. A game can be converted to a zero-sum game when the total amount won by the two players is the same for every combination of strategies. The payoff matrix for a zero-sum game is usually written showing just the amounts won by the player on rows. The player on columns wins the negatives of the values in the table. If every entry in a row is greater than the corresponding entry in another row, the first of these rows is said to dominate (or strictly dominate) the second of these rows. The player on rows would never choose a row that is dominated by another. If every entry in a row is greater than or equal to the corresponding entry in another row, and the two rows are not the same, the first of these rows is said to weakly dominate the second of these rows. There is no advantage for the player on rows in choosing a row that is weakly dominated by another. Similarly, one column dominates another if the payoff for the player on columns is better in every row (remembering that in a zero-sum game the player on columns wins the negative of the value in the table), or weakly dominates if they are better or equal (and not all equal). The play-safe strategy for either player is the strategy for which the worst possible score is best. There might be more than one play-safe strategy for either player. In a zero-sum game: For the player on rows, the play-safe strategy is the row for which the row minimum is largest (the row maximin). For the player on columns, the play-safe strategy is the column for which the column maximum is smallest (the column minimax). A zero-sum game is stable when the row maximin value equals the column minimax value. If both players play safe, neither of them will have any incentive to change. To find a Nash equilibrium, you first need to identify the cell(s) in each row where the player on columns gets the highest payoff ( value max in each row). Then identify the cells in each column where the player on rows gets the highest payoff ( value max in each column). If there are any cells that give a maximum column value for the row and a maximum row value for the column, then these are Nash equilibrium solutions. A game might have multiple Nash equilibrium solutions or it might have none. To find a mixed strategy for a player in an unstable game when a player has two options: Let the probability of playing the options be and

.

Calculate the expected payoff, in terms of , when the other player uses each of their options. Sketch a graph showing the expected payoff against for

.

The feasible region is the area below all the expected payoff lines for

.

Find the maximum feasible value of the minimum expected payoff by sliding a horizontal profit line up across the feasible region until it reaches the highest point. To find a mixed strategy for a player in an unstable game when a player has more than two options: Add a constant throughout the payoff matrix to make all the payoffs non-negative. Let the probability of playing the options be

Calculate the expected payoff, in terms of of their options.

when the other player uses each

Set up a linear programming problem: maximise subject to

(or

constant that was previously added).

expression for expected payoff for each option

and Use the simplex algorithm to find the values of

.

Mixed practice 8 1

Find the play-safe strategy for each player for this game.

Mina

Pav

2

Rose and Jim repeatedly play a zero-sum game. The payoff matrix for the game is:

Jim

Rose

a Explain why Rose should never play strategy . b Hence reduce the payoff matrix. 3

The payoff matrix for a zero-sum game is:

Player B

Player A

Player B chooses randomly between the columns so that column is played with probability and column with probability . a Find and simplify an expression for the expected payoff for player B when player A chooses each of strategies and . b Find the optimal mixed strategy for player B. 4

Find the play-safe strategy for each player for this game.

Bev

Avi

5

Robbie was given a new computer game for Christmas. He has already worked through

several levels of the game but is now stuck at one of the levels in which he is playing against a character called Conan. Robbie has played this particular level several times. Each time Robbie encounters Conan he can choose to be helped by a dwarf, an elf or a fairy. Conan chooses between being helped by a goblin, a hag or an imp. The players make their choices simultaneously, without knowing what the other has chosen. Robbie starts the level with ten gold coins. The table shows the number of gold coins that Conan must give Robbie in each encounter for each combination of helpers (a negative entry means that Robbie gives gold coins to Conan). If Robbie’s total reaches gold coins then he completes the level, but if it reaches zero the game ends. This means that each attempt can be regarded as a zero-sum game.

Conan

Robbie

Goblin

Hag

Imp

Dwarf Elf Fairy

a Find the play-safe choice for each player, showing your working. Which helper should Robbie choose if he thinks that Conan will play safe? b How many gold coins can Robbie expect to win, with each choice of helper, if he thinks that Conan will choose randomly between his three choices (so that each has probability )? Robbie decides to choose his helper by using random numbers to choose between the elf and the fairy, where the probability of choosing the elf is and the probability of choosing the fairy is . c Write down an expression for the expected number of gold coins won at each encounter by Robbie for each of Conan’s choices. Calculate the optimal value of . Robbie’s girlfriend thinks that he should have included the possibility of choosing the dwarf. She denotes the probability with which Robbie should choose the dwarf, the elf and the fairy as , and , respectively. She then models the problem of choosing between the three helpers as the following linear programming problem. Maximise subject to:

and d Explain how the expression

was formed.

Robbie’s girlfriend uses the simplex algorithm to solve the linear programming problem. Her solution has

and

.

e Calculate the optimal value of . © OCR, A Level GCE Decision Mathematics 2, Paper 4737, January 2010 6

For the game in question 2:

Jim

Rose

a Find the optimal mixed strategy for Rose. b Find the optimal mixed strategy for Jim. 7

Set up the initial simplex tableau to find the optimal mixed strategy for the player on rows for this zero-sum game.

8

A team from the Royal Hotel have challenged a team from the Carlton Hotel to a darts competition. In this competition there are seven rounds, and the teams must choose a player for each round, although players may play more than one round. Each round is made up of five ‘legs’ and the team that wins the most legs (out of ) wins the competition. On the basis of their performances so far, the number of legs that each member of the Royal team can expect to win (out of five) against each member of the Carlton team is shown below. Carlton Legs won Royal

Jeff

Kathy

Leo

Greg Hakkim Iona

The teams want to choose which player to put in for each round to maximise the number of legs they expect to win. a If the Royal team chooses Greg and the Carlton team chooses Jeff, how many legs will the Carlton team expect to win? To convert the game into a zero-sum game, each value in the table is doubled and then is subtracted. b Construct the resulting table for the zero-sum game. c Find the play-safe strategies for the zero-sum game, showing your working. Explain how you know that the game is not stable. State which player is best for the Carlton team if they know that the Royal team will play safe. d Use a dominance argument to explain why the Royal team should not choose Iona. The Royal team chooses a player for the next round by using random numbers to choose between Greg and Hakkim, where the probability of choosing Greg is and the probability of choosing Hakkim is . e Show that the expected number of legs that the Royal team win when the Carlton team chooses Jeff is given by and find the corresponding expressions for when Kathy is

chosen and when Leo is chosen. f

Use a graphical method to find the optimal value of for the Royal team, and calculate how many legs the Royal team can expect when this value of is used.

Suppose, instead, the team that wins the most rounds wins the competition. The winner of each round is the team that wins the most legs (out of five) in that round and there are still seven rounds in the competition. g Give an example to show that it is possible to win the most legs without winning the most rounds. © OCR, A Level GCE Decision Mathematics 2, Paper 4737, June 2013 9

Find any Nash equilibrium solutions for the following game.

10 The simplex tableau for finding the optimal mixed strategy for the player on rows in a zerosum game has rows and columns. How many strategies does each player choose between?

CROSS-TOPIC REVIEW EXERCISE 2 1

a Find the play-safe strategy for each player for this zero-sum game.

Player 2

Player 1

b Deduce whether the game is stable or unstable. c Advise player 1 on which strategy to play. 2

The table lists the activities involved in a project, their durations, in hours, and their immediate predecessors. Activity

Duration (hours)

Immediate predecessors

a Find the minimum project completion time. b List the critical activities. c How late could activity start without the minimum project completion time being affected? 3

Coloured paint is mixed using different ratios of red, yellow, blue, white and black paint. The total amount of paint used must not exceed one litre. The amount of black paint must be, at most,

of the total.

The amount of blue paint must be more than twice the amount of yellow paint. The desirability value of a mixed colour is given by the amount of blue plus the amount of black minus the amount of red. Formulate a linear programming problem to represent this information. 4

The table lists the activities involved in a project, their durations, in days, and their immediate predecessors. Activity

Duration (days)

Immediate predecessors

a Represent the project as an activity network. b Find the minimum project completion time. c List the critical activities. 5

a Carry out one iteration of this simplex tableau.

b Interpret the resulting tableau. c Describe the effect of the iteration geometrically. 6

a Find any Nash equilibrium solutions for the following game.

b Find the play-safe strategies. 7

a Use dominance to reduce this zero-sum game to a

game.



b Find the probabilities with which each strategy is chosen in an optimal mixed strategy. 8

a Write out the linear programming formulation that is represented by this initial simplex tableau.

b Carry out one iteration of the simplex algorithm. The final tableau is:

c Write down the optimal value of and the values of 9

and at optimum vertex.

The early and late event times, in days, for an activity network are given in the first table. The second table shows the activity durations and the number of workers that each activity requires (apart from ). Event Early event time Late event time Activity

Duration

Number of workers

a What is the maximum value of if the project can be completed by three workers in

days?

b Construct a schedule to show how project can be completed by three workers in the minimum possible time: i when ii when iii when State the minimum possible completion time for each case. c What is the minimum time needed when

and six workers are available?

, and 10 The constraints of a linear programming problem are , where and are slack variables. a A student claims that the first constraint means that is, at most, twice as large as . What should the student have said? b When

, what values can take?

The objective is to maximise

, where is a positive constant.

c Find an expression for the maximum value of when

.

d Use the constraints to deduce the maximum possible value of . e If the variables

and must be integer valued, find an expression for the maximum value of

when

.

PRACTICE PAPER Time allowed: hour

minutes.

The total number of marks is

.

The marks for each question are shown in brackets [ ]. 1

The diagram shows a simplified map of some towns and the motorway routes between them. C

F

B

H

E A

G

D

The motorway distances (

) between the towns are shown in the table.



– –



















– –







– –

















The total length of the motorways is

– –

– .

a Use an appropriate algorithm to find the shortest distance from to each of the other seven towns. [5] Harry is a motorway maintenance engineer. He needs to check all the motorways to make sure that there are no potholes. Harry works in town and lives in town He wants to find a route that starts at , ends at and covers each motorway shown on the map. b Deduce the minimum distance that Harry will need to travel. 2

[4]

Shuttle sort is to be used to sort a list of five numbers into increasing order. a Use the following list to demonstrate how the algorithm works.

[3]

b Find the number of comparisons used when the initial list is already in increasing order. Explain your reasoning. [2] c Find the number of comparisons used when the initial list is in decreasing order. Explain your reasoning. [2] d A computer using shuttle sort takes you expect it to take to sort a list of 3

seconds to sort a list of numbers?

The feasible region for a linear programming problem is given.

numbers. How long would [2]

y 6 4 2

O

2

4

x

The objective is to maximise

. The optimal solution is at the point

, to decimal

place. a Use the graph to deduce the optimal solution when and must be integers.

[1]

b Use the graph to demonstrate the use of branch-and-bound to solve the integer linear programming problem. You may estimate the solutions to the subproblems from the graph. [6] c In what situation would branch-and-bound be the best way to solve an integer linear programming problem? 4

[2]

The table lists the activities involved in a project, their durations (in hours) and their immediate predecessors. Activity

Duration (hours)

Immediate predecessors – –

a Find the minimum project completion time.

[3]

b Find the float on each activity, distinguishing between independent float and interfering float. Two workers are needed for each of activities , and . The remaining activities require one [3] worker each. c Find the minimum time in which the project can be completed by: i two workers ii three workers. 5

A graph has degree sequence

[4] .

a Explain why must equal .

[2]

b Deduce the number of arcs in the graph.

[1]

c Draw a simply connected graph with this degree sequence.

[1]

Phil wants to draw the graph as a design in icing on a small cake. He wants to ice the design without having to stop and start again and without repeating any lines. d Describe how you know that it is possible for Phil to do this for any connected graph with this degree sequence. [2] e Explain why if a graph with this degree sequence is not connected it is also not simple.

[1]

f

Explain why there is no graph with all of the following properties. It has vertices, each with degree at least . It has the same number of arcs as in part b. It is simple. It is not connected.

6

[3]

Alex and Bel play a zero-sum game. The payoff matrix is:

Bel





Alex





a Show how the game can be reduced to a

game.

[3]

b Find the play-safe strategy for each player.

[3]

c If it is known that Bel will use her play-safe strategy, which strategy should Alex use?

[1]

d Deduce whether the game is stable or unstable.

[1]

e Describe how Alex should choose which strategy to use to maximise his expected payoff over a number of games. [3] 7

A manufacturing process involves two checking stages. There are three different products that are manufactured. The times taken, in minutes, to check one part of each type at each checking stage are shown in the table. Product

Time for first check

The first checking stage is available for is available for

Time for second check

minutes each morning and the second checking stage

minutes each afternoon.

a Write this information as inequalities in variables that you should define.

[3]

The availability of materials limits the total number of product and product items manufactured to each day. Customer demand means that the number of product items should be at least twice the number of product items produced each day. The profit on each type item manufactured is £

, on each type item is £

and on each type item is £

.

b Formulate a linear programming problem to find the maximum profit.

[5]

c Carry out one iteration of the simplex algorithm.

[6]

The final tableau gives an optimal solution with

items of type manufactured each day.

d Deduce the number of items of type and type that are manufactured each day for this solution. Hence find the maximum profit. [3]

FORMULAE

The following formulae for Discrete Mathematics will be given on the AS and A Level assessment papers. Inclusion–exclusion principle For sets , and :

The hierarchy of orders

Sorting algorithms Bubble sort Start at the left-hand end of the list, unless specified otherwise. Compare the first and second values and swap if necessary. Then compare the (new) second value with the third value and swap if necessary. Continue in this way until all values have been considered. Fix the last value, then repeat with the reduced list until either there is a pass in which no swaps occur or the list is reduced to length , then STOP. Shuttle sort Start at the left-hand end of the list, unless specified otherwise. Compare the second value with the first and swap if necessary; this completes the first pass. Next compare the third value with the second and swap if necessary; if a swap happened, shuttle back to compare the (new) second with the first, as in the first pass. This completes the second pass. Next compare the fourth value with the third and swap if necessary. If a swap happened, shuttle back to compare the (new) third value with the second, as in the second pass (so if a swap happens shuttle back again). Continue in this way for passes, where is the length of the list. Quick sort The first value in any sublist will be the pivot, unless specified otherwise. Working from left to right, write down each value that is smaller than the pivot, then the pivot, then work along the list and write down each value that is not smaller than the pivot. This produces two sublists (one of which might be empty) with the pivot between them and completes the pass. Next apply this procedure to each of the sublists from the previous pass, unless they consist of a single entry, to produce further sublists. Continue in this way until no sublist has more than one entry. Network algorithms Dijkstra’s algorithm START with a graph, . At each vertex draw a box, the lower area for temporary labels, the upper lefthand area for the order of becoming permanent and the upper right-hand area for the permanent label. STEP 1 Make the given start vertex permanent by giving it permanent label and order label .

STEP 2 For each vertex that is not permanent and is connected by an arc to the vertex that has just been made permanent (with permanent label ), add the arc weight to . If this is smaller than the best temporary label at the vertex, write this value as the new best temporary label. STEP 3 Choose the vertex that is not yet permanent that has the smallest best temporary label. If there is more than one such vertex, choose any one of them. Make this vertex permanent and assign it the next order label. STEP 4 If every vertex is now permanent, or if the target vertex is permanent, use ‘trace back’ to find the routes or route, then STOP; otherwise return to STEP 2. Prim’s algorithm (graphical version) START with an arbitrary vertex of . STEP 1 Add an edge of minimum weight joining a vertex already included to a vertex not already included. STEP 2 If a spanning tree is obtained, then STOP; otherwise return to STEP 1. Prim’s algorithm (tabular version) START with a table (or matrix) of weights for a connected weighted graph. STEP 1 Cross through the entries in an arbitrary row, and mark the corresponding column. STEP 2 Choose a minimum entry from the uncircled entries in the marked column(s). STEP 3 If no such entry exists, then STOP; otherwise go to STEP 4. STEP 4 Circle the weight

found in STEP 2; mark column ; cross through row .

STEP 5 Return to STEP 2. Kruskal’s algorithm START with all the vertices of , but no edges; list the edges in increasing order of weight. STEP 1 Add an edge of of minimum weight in such a way that no cycles are created. STEP 2 If a spanning tree is obtained, then STOP; otherwise return to STEP 1. Nearest neighbour method START at a given vertex of . STEP 1 Find the least weight arc from this vertex to a vertex that has not already been included (or back to the start vertex if every vertex has been included). STEP 2 If no such arc exists, then the method has stalled so STOP; otherwise add this arc to the path. STEP 3 If a cycle has been found, then STOP; otherwise return to STEP 1. Lower bound for travelling salesperson problem START with all vertices and arcs of . STEP 2 Remove a given vertex and all arcs that are directly connected to that vertex; find the minimum spanning tree for the resulting reduced network. STEP 3 Add the weight of this minimum connector to the sum of the two least weight arcs that had been deleted. This gives a lower bound.

Route inspection problem START with a list of the odd degree vertices. STEP 1 For each pair of odd nodes, find the connecting path of least weight. STEP 2 Group the odd nodes so that the sum of weights of the connecting paths is minimised. STEP 3 Add this sum to the total weight of the graph, then STOP. The simplex algorithm START with a tableau in standard format. STEP 1 Choose a column with a negative entry in the objective row (or zero in degenerate cases). STEP 2 The pivot row is the one for which the non-negative value of the entry in the final column divided by the positive value of the entry in the pivot column is minimised. The pivot element is the entry of the pivot row in the chosen column. STEP 3 Divide all entries in the pivot row by the value of the pivot element. STEP 4 Multiples of the new pivot row are added to, or subtracted from, all other old rows so that the pivot column ends up consisting of 0s and a single 1, and corresponds to the new basic variable. STEP 5 If the objective row has no negative entries, then STOP; otherwise return to STEP 1.

Answers 1 Mathematical preliminaries Before you start… 1 2 1

3 5

4

9

7 2

6

8

Exercise 1A 1 a b 2 a {Numbers that are not multiples of } b 3 4 a For example: What size tin does the recipe require? b For example: What is the maximum number of standard-sized flapjack slices that Wamil can make? 5 a b c 6

7 a For example: b In every two turns at least is added and six lots of , so the maximum number of turns is . In each turn there are four choices. This gives an upper limit of possibilities, but the actual number will be significantly less than this. c d For example:

means that

, but if

, then is at most .

taking four turns.

8 Each of the numbers can be paired with another to make a sum of There are such pairs, and these form pigeonholes. If numbers are chosen, then at least two must be from the same pigeonhole and hence must sum to . 9 a Use the pigeonhole principle where each prime number has a pigeonhole and two numbers can share a pigeonhole if the smaller is a factor of the larger. There are eight primes less than ; namely, and . If nine numbers are chosen, then at least two must be from one box. b

10 If there are people in the room, then the number of acquaintances that each person can have must be one of . If the people all have different numbers of acquaintances, then each of the values must occur. But if one person has acquaintances, then least two people have the same number of acquaintances.

is impossible. So at

11 a B, D and E b

;

;

c 12

Exercise 1B 1 2 3 4 a b 5 a b c 6 a b c 7 8 9 10 a b c d 11 a b 12 a b

Mixed practice 1 1 a For example, there is at least one time when Folomi wants to record three programmes and none of them are available on b For example:

or catch-up.

Time

Time

Use catch-up for and . 2 a b This is the only number that is in both and . If a multiple of is which gives and

then

. The only prime that is

.

3 a b 4 a The first letter cannot be , so it must be or . If the first letter is then the third letter cannot be , so the only derangement is If the first letter is then the second letter cannot be , so the only derangement is

. .

b 5 a b 6 a b c 7 a i For example: ii b i For example: ii c 8 9 a The units digit of a square number must be one of the numbers or . Use the pigeonhole principle with six pigeonholes corresponding to the units digit of the square. At least two of the numbers must share a pigeonhole so that their squares have the same units digit and the difference of their squares is a multiple of .

b 10 a b c

2 Graphs and networks Before you start… 1 Each word maps to the number of letters in the word.

Exercise 2A 1 2 a For example: b For example: c For example:

and

3 The graph is connected but not simple. There are two arcs that form direct connections between and . 4 a b Remove and add

.

5 a b c d 2

6 a

3

1

4 6 5

b For example: c For example: 7 a For example: b 

degrees

degrees

degrees

The three graphs have different numbers of vertices of degree . 8 a The sum of the degree must be even so there must be two odd degrees. is the only odd vertex in the list, so the missing value must also be odd. b c 9 a

which is odd, but for every graph the sum of the vertex degrees is even.

b For a simple graph with four vertices the maximum vertex degree is . Here there is a vertex of order , so this vertex is either directly connected to one of the other vertices more than once or is directly

connected to itself. c i ii iii 10 a Proof b 11 a b c 12 Proof

Exercise 2B 1 Proof 2 3 Semi-Eulerian. It has exactly two odd degree vertices (the two vertices of degree ). 4

and

5 a b 6 a For example: b For example: 7

1,1,2,2,3,3

1,1,1,2,2,3

1,1,1,1,2,4

1,1,1,2,2,3

1,1,1,1,3,3

1,1,1,1,1,5

8 a b 9 a The complete graph contains a Hamiltonian cycle for . can be represented as a polygon with vertices and every pair of vertices joined. A cycle through the vertices can be formed by travelling around the outside of the polygon. b The complete bipartite graph contains a Hamiltonian cycle when is because any path will alternate between the two sets.

, but not otherwise. This

10 The total number of vertices is . Each of the vertices in one set has vertex degree and each of the vertices in the other set has vertex degree . The minimum sum of the vertex degrees for nonadjacent vertices is twice whichever is the smaller of and . This is smaller than , except when . Ore’s theorem shows that the graph is Hamiltonian when but is inconclusive when .

11 a

and

b Proof c Proof d Proof e 12 a b Proof c

Exercise 2C 1 

Vertex

In-degree Out-degree 2 3 Proof 4 a Proof b Proof 5

10

6 a A

C

7

12

5 8

B

D

b 7 a In-degree Out-degree b Proof 8 a b FWGC FWG FWC

WC c 9 a b Proof

W

FGC FG

G

C (or the same with

and swapped).

c Proof d Proof 10 a b c Proof

Mixed practice 2

2

1 a

4

8

5 7

b 2 Proof 3 Proof 4 a b It is non-planar. 5 a

and

b Proof c Proof 6 a i ii Proof iii Proof b

c

7 a b c 8 a b Proof c Proof 9 a Proof

,

b Proof c d

e 10 a For example: b Proof c Proof d Proof

3 Algorithms Before you start… 1

,

,

,

Exercise 3A 1 a b 2 The values of will all be positive, so the process is not finite. 3 

Print STEP 1 STEP 2 STEP 3 STEP 4 STEP 6 STEP 2 STEP 3 STEP 4 STEP 6 STEP 2 STEP 3 STEP 4

4 a i ii iii

y

b i

3 2 1 –3 –2 –1 O –1 –2 –3

1

2

3

x

y

ii

3 2 1 –3 –2 –1 O –1

1

2

3

x

–2 –3 c Non-negative integers 5

6 For example: The method finds the positive root of this equation but there is a second (negative) root that is missed, so it does not solve the problem. The method is unique to this particular case and is not a general approach. 7 a

b

, , , , , , numbers.

,

,

,

,

,

,

,

,

,

,

,

,

,

. The first

Fibonacci

is a counter to force the algorithm to finish in a finite time. It also determines how many Fibonacci numbers are displayed .

8 a For example: Does INT b i



STOP

ii





iii



STOP

?

STOP

c For example: Insert a decision box asking if immediately before the decision box asking if is a factor of . If the answer is NO, then continue with the process. If the answer is YES, then display the word ‘prime’ and then STOP. 9 a b Proof

c Proof d Powers of 10 a 

STEP

Output b Output is the product of the input values. c

is the sum of the values when is odd. The original value of is written as a sum of powers of (e.g. ) and the successive doubling of gives , , and so on. is the sum of the multiples that are the powers of that make .

Exercise 3B 1

seconds

2 3 4

seconds

5 a b 6 7 a b c 8 Over

million years

9 10

Exercise 3C 1

passes

2 Sum of masses

.

so bins are not enough.

3 a Decreasing; the final value is fixed after the st pass and this is the smallest value. b

( swaps)

4 The , , and must be in separate bins. 5 a

b

6 Full-bin and first-fit decreasing need the whole list available at the start, so they are not appropriate for an online problem. The bin capacity must be at least , because of bin . If first-fit had been used the would have fitted after the in bin , so next-fit was used. The bin capacity cannot be because the would have fitted after the in bin , so the bin capacity is at least and less than . bin capacity 7 a

b

c part a: and

, part b:

8 a b Bubble sort 9 a Bag of mass

:

b Proof c 10 a b Proof c Two

lengths

Mixed practice 3 1

; bag of mass

:

2

days (and hours,

minutes,

3 

seconds, approx.) Display

4 5 a 

Print

b 

Print

fail c Example: The algorithm tries to find two integers, and , with of is checked starting at and increasing until is no longer longer and line stops the algorithm when it has failed. 6 a Proof b

, using the dominant term.

c 7 a Let b Let

and

.

original value of

c 

8 a 

After st pass After nd pass After rd pass After th pass

original value of

.

and . Line

. The value

checks when is no

b

The total area is

square inches, so at least two trays are needed.

The by slab cannot fit the other way round and the only slab that can fit in the same tray with it is the by slab. This leaves square inch unused. So three trays are needed. c

Yes, for example, the two by slabs can be rotated and packed side by side in one tray, and the two by slabs rotated and packed alongside the by slab. 9 a b 10 a  comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons comparisons

comparisons comparisons comparisons b c

4 Network algorithms Before you start… 1

seconds,

seconds

Exercise 4A 1

V

W 4

Y

4

4

10

7 5 9

S 3

... 9

2

2 X

5

9

11

9

Z

The next permanent label is 2

.

was not updated when STEP 2 was used from , so must have been chosen as the first permanent vertex with label less than or equal to . There must be an arc from to with weight at most . Arc weight arc weight of .

3

seconds

minutes 6

4 a B

12 A

5

8

F

7 9 6

5 8

6

D

3

8

10

10

9

C

7

G

3

E 8

b













5







to :









, to :

So













.

.

6 a







































b £ c £ 7 a Dijkstra’s algorithm b











































c The route from part b is via London. The shortest route does not go through London. d The average speed is different for different roads. The quickest route might use more motorways than the shortest route or avoid travelling through town centres. 8 Proof 9 a b c d

Exercise 4B 1 2 3

seconds

hours

minutes

4 For example: Kruskal

A

D

B

E

C

F

Total weight

Prim from

5 Proof 6 7 a b

because without this, getting from to using shelters means travelling

.

8 a Proof b For example: c For example:

and no other arcs to , with all other arcs shorter than

9 a b c 10 In a spanning tree it must be possible to get from any vertex to any other vertex. If there is a directed arc, then there must be a way to get from the end of the arc to the start, and that means that there is a set of arcs that form a cycle.

Exercise 4C 1 2 3 4 a

and

; and

;

b 5 a

and

;

or

;

b 6 a There is no cycle because to travel in and out of the arc repeated.

must be travelled twice, so is

b c d 7 a MST for reduced network

, £

b £ 8 It is a ‘string’ (a tree with just two vertices of degree ). The two least weight arcs from the vertex that was reduced join it to the ends of the string. 9 a Proof b Twice the weight of the tree

Exercise 4D 1

, and (but with start and end at different vertices for )

2

and

3

4 Sum of weights 5

(each arc appears twice in the table),

litres

6 a b Proof c

d Proof 7

,

8 a b



metres 9 a Proof b Proof c Over

minutes

Mixed practice 4 1 a



























K





J

L

M N

,

,

,

b Prim’s algorithm in tabular form, starting at . c 3 a



























b Greater than 2 a









b 4 Proof 5 a i

Kruskal’s algorithm (or Prim’s algorithm in network form)

ii iii Not unique, there are two spanning trees with total weight

.

b It will be scaled by a factor of . 6 a b

and

c

and

d

, there may or may not be arcs from to the other vertices.

and/or

7 a £ b £ c £ d £ e £

£

cost

8 a





















miles b Route inspection c



Length of route and

e f g









d



,

miles

miles stall

miles miles

















9 10 a b

Cross-topic review exercise 1 1 a After After After After After b i ii

st pass nd pass rd pass th pass th pass

comparisons swaps

2 a Dijkstra’s algorithm b

































































3 a Proof b c Proof d For example:

STEP





c

4 a 



List

b i

For example:

ii

For example:

c i  

ii  

iii 5 a b c 6 a

b i ii

£

iii c i ii d £

cost

£

7 a Each vertex has degree , so deg

deg

for each pair of non-adjacent vertices and . The

graph is Hamiltonian. b Graph cannot contain example, c

since no vertex has degree . Graph is not isomorphic to

E

A

D

since, for

form a cycle. So graph is planar.

F

B

C

8 a b Proof c 9 The three empty chairs partition the chairs into four sets. Each non-empty set consists of chairs with people sitting in them. Since

, there is at least one set with more than chairs (between a pair

of empty chairs). 10 a b

seconds

c d Time (s) Successive ratios



The ratios increase (by approximately ) as increases by .

Successive ratios



Successive ratios decrease, so not polynomial.

Successive ratios



Successive ratios are constant, so not exponential.

5 Decision making in project management Before you start… 1

Exercise 5A 1 2 3

hours

4 a

, and must all be finished before can start, but only and need to be finished before can start.

b Otherwise and would share a start event and also share a finish event. c 

Activity

Immediate predecessors

5 a

,

,

,

b

,

,

,

c

, ,

and R(16)

6 a P(10)

S(15)

U(14)

Q(8) T(12)

b

days

7 a b

hours

c 

Activity Float Activity Float

d 8 a b

and hours ,

,

9 a

days

b

and

c

Exercise 5B 1

hours

2 a

days

b

days

3 a

weeks

b weeks 4 5

hours (activities

and

)

R P Q 0

6 a

2

S 4

6

8

T 10

12

Days

minutes

b minutes 7 For example: Time

Worker 1

Worker 2

Worker 3

8 a Proof b Proof c

days

d days 9 a

minutes

b

minutes

c

minutes

Mixed practice 5 1 a

8

8

C(3)

12 12

A(8) 0

F(6) D(4)

0

18 18 G(4)

B(5) 8

8

E(5)

13 14

b Minimum project completion time

hours

c Critical activities are , and . 2 a i Minimum project completion time is unchanged. ii

, and are still critical, but now and are also critical activities.

b

hours,

3 a 

hour

Activity

Independent float

Interfering float

b 4 One dummy is needed from the end of to the end of , so that S follows but not necessarily , while , follow both and . second dummy is needed either before or after or , so that and do not start at the same event and also finish at the same event. 5 a b c d

hours (or

minutes)

6 a, b 8 12

0

F(4)

B(9)

0 C(7)

D(5)

17 17

E(6)

A(8)

9 10 I(10) 7

7

L(7) M(6)

G(5)

16 18 J(9) K(6)

H(6) 15 16

N(8)

24 24

c Minimum completion time d

hours

, ,

7 a 3 4 3 2 1 3 1 Hours 0

2

2

4

6 12 18 24 30 36 42 48

b Two workers do the critical activities and then . 8 a

8

G(2)

5 5 0

followed by



; the other two workers do



,



I (4)

D(3)

A(2)

0

8



F(3) 8

E(5)

8 J(1)

C(2)

12 12

10 11 B(3)

3

3

H(3)

b Minimum project completion time

hours, Critical activities: , , ,

c For to happen, , and must already be completed. Sally cannot do any of , and . If they share and , these take hours. Sally cannot help with , so this takes Tariq another hours. d Proof,

hours

e Proof,

hours

f For example, share and , Tariq does , share , , and , Tariq does and , Sally does .

6 Graphical linear programming Before you start… y

1 8 7 6 5 4 3 2 1

–1 O –1

1

2

3

4

x

2

Exercise 6A 1

2

3

number of type items produced each day, number of type items produced each day. These are really average numbers because on any individual day the number could be a fraction, but over a number of days there will be whole numbers of items.

4 Maximise

subject to: mixing time finishing time and

5

amount of Xtra (litres), Maximise subject to: or or or or

6

amount of Yepp (litres)

7

and (from ) and Also

so

(from ) and

which is , so

and

. so

, which is

.

8 a b

Exercise 6B 1 Proof 2 Proof 3 a

or

or

b

or or

or

or

4 a b

c 5 For

the optimal vertex is

vertex is

. For

, the optimal vertex is

.

Exercise 6C 1 2 3 4 Maximise

Maximise

subject to:

subject to:

5

when

6

when

7

at

8

at

and

Mixed practice 6 1 a

when

b

when

c 2

and and

. For

, the optimal

3

when

4 a Maximise

(pence) subject to:

both integers.

and

b loaves and trays of buns c £ d He might not sell all the loaves and buns. 5 a

area of panelling

,

area that is painted

,

area of pinboard

b Proof c

(minutes) (or any positive multiple of this)

d Minimise subject to:

(or any positive multiple of

plus or minus a constant (or zero))

e

The feasible region is the small triangle

and

.

y

6 a

3x – 2y = 12

8

3x – 8y = –24

6 4 2

Feasible region

O

2

b

and .

c 

4

3x + 4y = 30 6

8

10

. Optimal when

x

with a maximum value of the objective

Optimal when

.

7 a Customer buys bags of type , of type and of type . Hats: Puzzles: So

.

But

and hence

.

b Type C have no jokes but the customer wants at least jokes. c Jokes: Hats:

so

and

so

.

Puzzles:

so

Hence

and

These contain 8

.

. .

sweets.

P = 30 at (0, 7.5) y ⩽ 7

y ⩾ 8

P = 28.75 at (0.25, 7) x ⩽ 0 P = 28 at (0, 7)

Infeasible

x ⩾ 1 P = 25 at (1, 5.5)

Optimum is

at

.

7 The simplex algorithm Before you start… y

1 6

5x + 3y = 15

4 2

4x + 5y = 20

O

2

4

6

8

x

2

Exercise 7A 1 

2

in column row

3 Yes, because there are no negative values in the objective row. 4 5

in column row (there are no positive entries in column ).

6 

7 8 a It reaches this tableau.

The current solution is b The original problem was maximise

, subject to:

, , , .

, does satisfy both constraints and gives

.

9 a b There is a in the objective row (other than in basic columns). c Pivot on column to give:

d The degenerate column is now , but if that is used as the pivot it will just go back to the solution from part a.

Exercise 7B 1 a Line b Line c Line 2

,

and

3 Maximise

subject to:

4 a 

b Move along the edge

from

to

(i.e.

).

5 a 

b Move along the edge 6 7 a 

or

from ,

to

(i.e.

).



b Move along the edge then move along the edge

from from

to

to to

. (i.e. (i.e. from

).

Mixed practice 7 1 Current solution has

, but this is not optimal because there is still a negative value in the

objective row, so maximum value is at least than 2

3

.) (optimum has been achieved) ,

in row of column.

4 Maximise

subject to:

5 a Proof b

so

c d £ e Pivot on the in row of column .

New row

row

New row

row

New row

row

. (The ratio

so the maximum value is greater

),

New row

row

New row

(row )

f No negative values in objective row g

. Tammy should make litres of amber lotion and

£

Maximum profit h

so

6 a

. Might be less because she might not sell it all. (or calculate

,

b 

Pivot on the

in the column.

New row

row

New row

row

New row

row

New row

row

litres of bronze lotion.

Pivot on the in the column. New row

row

New row

row

new row

New row

row

new row

New row

row

new row

). She needs at least

litres of water.

Make litres of fruit salad only. c Proof 7 a 



b Move along the edge then move along the edge to

from from ).

to to

, (i.e. (i.e. from

),

8 Game theory Before you start… 1

2

,

,

Exercise 8A 1 Proof 2 Proof 3 Proof 4 Proof 5 

Bob

Alice

6 Play-safe strategy for Rupi is . Play-safe strategy for Sandi is . 7 a 

Fionn

Gina

b Unstable c No dominance 8 9 Stable for

Exercise 8B 1 2 3 

.

4

,

5 a Ben chooses randomly between the rows so that row is played with probability probability .

and row with

b c 6

rows and

columns

7 

8 

Mixed practice 8 1 Play safe for Pav is . Play safe for Mina is . 2 a Proof b 

Jim Rose

3 a b Choose randomly between the columns so that column is played with probability with probability

.

4 Play safes for Avi are and . Play safe for Bev is . 5 a Play safe for Robbie is fairy, play safe for Conan is hag, Robbie should choose the elf. b Dwarf:

and column

Elf: Fairy: c Goblin:

; Hag:

; Imp:

.

so

.

d is added throughout the table to make all the entries non-negative. If Conan chooses the goblin, this gives an expected value (in the new table) of

.

e 6 a Rose chooses randomly between the rows so that row is played with probability probability .

and row with

b Jim chooses randomly between the columns so that column is played with probability column with probability .

and

7 

8 a b 

Jeff

Kathy

Leo

Greg Hakkim Iona c 

Jeff

Kathy

Leo

Row min.

Greg Hakkim Iona Col. max. Play safe for Royal team is Greg, play safe for Carlton team is Kathy. Not stable since team play safe, Carlton team should choose Jeff.

. If Royal

d Proof e Proof. Kathy: f

. Expect to win

g One team could win has won rounds and

, Leo: legs. legs, then they have won rounds but only legs.

legs, and other team

9 10 Rows

, Columns

Cross-topic review exercise 2 1 a Player 1: Player 2: b Stable (since value of play-safe strategy

for both players).

c Always choose strategy . 2 a

hours

b c 3

hours

amount of red (litres), amount of yellow (litres), amount of white (litres), amount of black (litres) Maximise subject to:

amount of blue (litres),

.

E(2)

C(2)

4 a

A(3)

F(3)

B(1) D(4) b days c 5 a 

b The maximum value of is

when

.

The first constraint is at its limit; the others still have slack. c Start from

and move along the edge ).

6 a b

and

7 a Reduced game:

to

(the vertex



b  Strategy Probability Strategy Probability 8 a Maximise

subject to:

b 

c

when

9 a b i For example: Worker 1 Worker 2 Worker 3 Nobody days ii For example: Worker 1 Worker 2 Worker 3 Nobody days

and

.

iii For example first days, as above, then: Worker 1 Worker 2 Worker 3 Nobody days c

days because still has to follow .

10 a

is at least twice as large as .

b c

if

d

if

.

, from the first constraint, and so

.

, so

from the second constraint,

.

e

Practice paper 1 a Use Dijkstra’s algorithm, starting from .

































Shortest distance from





















:

b 2 a Compare the first two numbers and swap if necessary.

Compare second and third numbers, swap if necessary, if a swap occurred compare the first and (new) second numbers and swap if necessary.

Work along the list until every number has been considered. For a list of numbers this will be after passes. Third pass:

No swap so continue straight on to fourth pass. Fourth pass:

b c d million seconds just over

days.

3 a b

P = 5.1 at (1.8, 3.3) x ⩽ 1

x ⩾ 2

P = 3.8 at (1, 2.8) y ⩽ 2 P = 3 at (1, 2)

P = 5 at (2, 3)

y ⩾ 3 Infeasible

The best integer-valued solution is

at

.

c When there are more than two variables, the feasible region cannot be graphed, but the simplex algorithm can be used to solve the subproblems in branch-and-bound. 4 a

hours

b 

Activity Independent Interfering

c i

hours

ii

hours

5 a The degree sequence is an ordered list of the degrees, so can only be , or . The sum of the degrees must be even (there is always an even number of odd vertex degrees), so must be . b c

d There are exactly two odd degrees ( and ), so the graph is semi-Eulerian and can be drawn as required, with the vertices of degree and degree as the end points. e For a simple graph the vertex of degree must be connected to each of the other vertices. If the graph is not connected, then there is either a loop or a repeated arc from the vertex of degree . f If the graph is not connected but has vertices each with degree at least , it must be made of two disconnected subgraphs: one with vertices and the other with vertices. If the subgraphs are simple, the maximum number of arcs is when they are and are required.

and

, but this only gives

arcs

6 a Proof b Play safe for Alex is , play safe for Bel is . c d Unstable since

.

e Choose randomly between rows so that row is chosen with probability and row with probability . 7 a

number of product items manufactured each day number of product items manufactured each day number of product items manufactured each day Time for first check: Time for second check:

b Maximise

subject to:

c 

Pivot on the in row of column .

d

and and Maximum

£

so , so

type items. .

Glossary ABS

: This gives the absolute value, or modulus, of . For example,

.

Ad hoc method: An ‘impromptu’ strategy that is ‘not planned beforehand’ but might be unique to a particular problem, rather than being a general strategy. Adjacency matrix: This shows the number of arcs that directly join pairs of vertices. Adjacent: Two vertices are directly connected, or adjacent, if there is an arc with these vertices at its ends. Algorithm: A step-by-step process or set of rules. An algorithm needs an input and an output, must be deterministic and must be finite. Arc (or edge): A line or curve with a vertex at each end. Arrangement: An arrangement of distinct objects is a rearrangement of the objects. The number of arrangements of objects from distinct objects is called the number of permutations of objects from and is written as or . Basic variable: A variable that corresponds to a column in a simplex tableau consisting entirely of s apart from a single . Bipartite graph: The vertices of a bipartite graph can be partitioned into two sets so that every arc joins a vertex from one of these sets to a vertex in the other set. No arc connects two vertices that are in the same set. Branch-and-bound: A method for finding solutions of integer programming problems. Bubble sort: An algorithm for sorting items by making passes along a list. Each pass starts at the beginning and compares adjacent pairs along the list, swapping if necessary, until the end of the list is reached. The last item is then fixed and a pass carried out on the reduced list, until either there is a pass in which no swaps occur or the list is reduced to length . Chinese postman problem: The problem of finding a least weight route that uses every arc of a network. This is also called the route inspection problem. Combinations: See selections. Complete graph: A simply connected graph with the maximum possible number of arcs. Connected: A graph is simply connected if it is possible to get from any vertex to any other, directly or indirectly. Contraction: Removing an arc from a graph and merging the two vertices that it previously joined. Counter: A value that indicates how many times a process should loop back on itself. Critical activity: In critical path analysis, a critical activity is any activity for which the activity duration is the same as the difference between the early event time for the event at the beginning of the activity and the late event time for the event at the end of the activity. An activity with zero float. Cycle: A closed path in a graph (a path with an extra arc that joins the end vertex back to the start vertex). Degenerate solution: In linear programming, an optimal solution that is not unique. Degree of a vertex: The number of arcs at that vertex (the number of arcs incident on the vertex). Degree sequence: A list of the vertex degrees of a graph, written in increasing order.

Derangement: A rearrangement of an ordered list in which no element is in its original position. Digraph: A graph with directed arcs. Dijkstra’s algorithm: An algorithm for finding a least weight path between two given vertices in a network of undirected arcs with non-negative arc weights. Dominate: In game theory, a strategy dominates another for a player when, for each choice by the other player, the dominating strategy is better for this player than the other strategy. Early event time: In critical path analysis, the earliest time at which every activity leading into an event can be completed (the maximum of such times). Euler’s relation: For any planar graph

.

Eulerian graph: A simple connected graph with no vertices of odd degree. Feasible region: The region in which all the constraints of a linear programming problem are satisfied. First-fit method: In bin packing, starting at the left-hand end of the list and packing each item in the first bin that has enough space for it, starting from the first bin each time. First-fit decreasing method: In bin packing, sort the items into decreasing order and then use first-fit method. Float (or total float): In critical path analysis, the amount by which the difference between the early event time for the event at the beginning of an activity and the late event time for the event at the end of the activity exceeds the activity duration. Full bin method: An ad hoc method in bin packing that involves trying to make full bins first. Greedy method: Making decisions using the choice that seems best at that moment, without regard to the bigger picture, in the hope that this will lead to the optimal solution. Hamiltonian graph: A graph that contains a cycle that passes through every vertex (exactly once). There will usually be arcs in the graph that are not used in the cycle. Heuristic: Any method that finds good solutions quickly or easily, but the solutions are not guaranteed to be optimal (although they might be). Inclusion–exclusion principle: • •

In-degree: The number of arcs that enter a vertex in a digraph. Independent float: The amount of time by which an activity can be delayed with no effect on any other activity. The amount by which the difference between the late event time for the event at the start of the activity and the early event time for the event at the end of the activity exceeds the activity duration, if this is positive, and zero otherwise. Interfering float: Total float minus independent float, for any activity. INT( ): This gives the integer part of the number . For example,

.

Integer programming problem (ILP): A linear programming problem for which the solutions must be integer-valued. Isomorphic graphs: Two graphs are isomorphic if they have the same structure.

Knapsack problem: An extended bin packing problem in which each item also has a value and it is required to pack (some of the) items into a fixed number of bins so that the total value of those items is maximised. Kruskal’s algorithm: A way of finding a minimum spanning tree for a network by working down a list of the arcs in increasing order of weight and choosing an arc that does not create a cycle with those already included. Kuratowski’s theorem: This says that a necessary and sufficient condition for a finite graph to be planar is that it does not contain a subgraph that is a subdivision of or . Late event time: In critical path analysis, the latest time at which every activity leading from an event can be started without delaying the entire project (the minimum of such times). Linear programming problem (LP): A problem that requires the optimisation of a linear function of the variables subject to a number of linear constraints in those variables. Loop: An arc in a graph that directly connects a vertex to itself. Maximin: The maximum of the possible minimum outputs. For example, in a zero-sum game, the play-safe strategy for the player on rows is the row for which the row minimum is largest (the row maximin). Minimax: The minimum of the possible maximum outputs. For example, in a zero-sum game, the play-safe strategy for the player on columns is the column for which the column maximum is smallest (the column minimax). Minimum spanning tree or minimum connector: A least weight tree connecting all the vertices of a network. Multiplicative principle: If there are ways of doing one thing, and for each of these there are ways of doing another thing, then there are different ways of doing both things. Nash equilibrium: In game theory, for each row identify the cells for which the player on columns gets the highest payoff, for each column identify the cells for which the player on rows gets the highest payoff. Any cell that is in both lists is a Nash equilibrium. Network: A weighted graph. This means that the arcs of the graph have numerical values (weights) attached to them. Next-fit method: In bin packing, starting at the left-hand end of the list and packing each item in the next bin that has enough space for it, starting from the bin that has just been used. Non-basic variable: A variable that takes the value and corresponds to a column in a simplex tableau that does not consist entirely of s apart from a single . Offline: A problem where the whole list of items is known at the start. Online: A problem where the items are released one at a time. Order of an algorithm: The order of an algorithm is given by the dominant term in the run-time for a large-scale problem. Ore’s theorem: For a simply connected graph with vertices, if the sum of the vertex degrees for every pair of non-adjacent vertices, then is Hamiltonian. Out-degree: The number of arcs that come out of a vertex in a digraph. Partition: Any way of splitting the elements of a set into non-empty subsets so that each element is in a subset (the union of the subsets is the whole set) and each pair of subsets are disjoint (have no intersection) so there is no element that is in more than one subset.

Path: This is a trail in which no vertex is repeated. Payoff matrix: A matrix that shows the amount that each player wins for each combination of strategies in a two-person simultaneous play game. Permutations: The number of arrangements of objects from distinct objects is called the number of permutations of objects from and is written as

or

.

Pigeonhole principle: If a set of elements is partitioned into subsets with least one subset with two or more elements in it.

, there must be at

Planar graph: Any graph that can be drawn with no arcs crossing (can be drawn as one layer, although it may be shown with arcs that cross). Play-safe: In game theory, a play-safe strategy is a ‘least worst’ strategy. Consider the worst possible outcome for each strategy and choose the one for which this is best. Prim’s algorithm: A way of finding a minimum spanning tree for a network by starting with a vertex and repeatedly adding an arc of minimum weight that directly connects a vertex already included to one that is not yet included. Quick sort algorithm: A method of sorting a list by comparing items with a pivot value. The pivot is usually the first value in each sublist. Work along each sublist to find the values that are smaller than the pivot, then write the pivot and then write the values that are greater than the pivot. Recursive: Processes that can be repeated by looping back to a start point. Route: A general term that includes walk, trail, path and a closed version of any of these. Route inspection problem: The problem of finding a least weight route that uses every arc of a network. It is also called the Chinese postman problem. Run-time: The run-time for an algorithm depends on the size of the problem. The maximum run-time in the worst case is usually considered. Selections: The number of selections of objects from distinct objects is called the number of combinations of objects from and is written or . Semi-Eulerian graph: A simple connected graph with exactly two vertices of odd degree. Shuttle sort algorithm: A method of sorting items in a list by comparing adjacent values and swapping if necessary, then shuttling back if a swap was made. Pass starts by comparing item and item . Simple: A graph is simple if there is exactly one arc between any two adjacent vertices and there are no loops. Simply connected graph: A graph that is both simple and connected. Slack variables: Non-negative variables that are added to the linear functions of the variables in a linear programming problem to turn inequality constraints into equations. Spanning tree: A tree that connects all the vertices in a network. See also minimum spanning tree or minimum connector. Stable game: A zero-sum game is stable if the row maximin value equals the column minimax value. Neither player has any incentive to change from their play-safe strategy. Stopping condition: A condition that is built into an algorithm to ensure that it is finite. Subdivision: This means inserting a vertex of degree into an arc of a graph; for example, insert vertex into arc so that the arc becomes and .

Subgraph: A subgraph of a graph is formed using some of the arcs of the graph together with the vertices that these arcs connect and possibly some other unconnected vertices. Thickness: The thickness of a graph is the minimum number of planar graphs into which the arcs can be partitioned. Total float: See float. Tour: A closed route through every vertex of a graph that can pass through vertices more than once. Trail: This is a walk in which no arcs are repeated. Travelling salesperson problem (TSP): This involves finding a least weight cycle through all the vertices of an undirected network. Traversable graph: A graph that can be drawn without taking your pen from the paper and without going over the same arc twice. Tree: A simply connected graph with the minimum possible number of arcs. Vertex (or node): A point in a graph. Vertices may be connected together by arcs. Walk: A connected subgraph consisting of a set of arcs where the end vertex of one arc is the start vertex of the next. Weighted matrix: A simple network can be represented using a weighted matrix, showing the weight of each arc and a blank, – or for vertices that are not adjacent. A weighted matrix is usually a distance matrix or a travel time matrix or a cost matrix. Zero-sum game: This is a game between two players in which, for every combination of strategies, the amount that one player wins equals the amount that the other player loses.

Acknowledgements The authors and publishers acknowledge the following sources of copyright material and are grateful for the permission granted. While every effort has been made, it has not always been possible to identify the sources of all the material used, or to trace the copyright holders. If any omissions are brought to our notice, we will be happy to include the appropriate acknowledgements on reprinting. Thanks to the following for permission to reproduce images: Cover image: huskyomega/Getty Images Awesh Shrivastava / EyeEm/Getty Images; Westlight/Getty Images; KTSDESIGN/SCIENCE PHOTO LIBRARY/Getty Images; BlackJack3D/Getty Images; Tracy Packer / Contributor/Getty Images; Adam Gault/Getty Images; naqiewei/Getty Images; Stocktrek Images/Getty Images; ilbusca/Getty Images.

University Printing House, Cambridge CB2 8BS, United Kingdom One Liberty Plaza, 20th Floor, New York, NY 10006, USA 477 Williamstown Road, Port Melbourne, VIC 3207, Australia 4843/24, 2nd Floor, Ansari Road, Daryaganj, Delhi – 110002, India 79 Anson Road, #06–04/06, Singapore 079906 Cambridge University Press is part of the University of Cambridge. It furthers the University’s mission by disseminating knowledge in the pursuit of education, learning and research at the highest international levels of excellence. www.cambridge.org/ Information on this title: www.cambridge.org/9781108444316 ISBN 9781108444316 (Cambridge Elevate 2 Year) ISBN 9781108445191 (Cambridge Elevate Site Licence) © Cambridge University Press 2018 This publication is in copyright. Subject to statutory exception and to the provisions of relevant collective licensing agreements, no reproduction of any part may take place without the written permission of Cambridge University Press. First published 2018 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 A catalogue record for this publication is available from the British Library Cambridge University Press has no responsibility for the persistence or accuracy of URLs for external or third-party internet websites referred to in this publication, and does not guarantee that any content on such websites is, or will remain, accurate or appropriate. NOTICE TO TEACHERS IN THE UK

It is illegal to reproduce any part of this work in material form (including photocopying and electronic storage) except under the following circumstances: (i) where you are abiding by a licence granted to your school or institution by the Copyright Licensing Agency; (ii) where no such licence exists, or where you wish to exceed the terms of a licence, and you have gained the written permission of Cambridge University Press; (iii) where you are allowed to reproduce without permission under the provisions of Chapter 3 of the Copyright, Designs and Patents Act 1988, which covers, for example, the reproduction of short passages within certain types of educational anthology and reproduction for the purposes of setting examination questions. This resource is endorsed by OCR for use with specification AS Further Mathematics A (H235) and specification A Level Further Mathematics A (H245). In order to gain OCR endorsement, this resource has undergone an independent quality check. Any references to assessment and/or assessment preparation are the publisher’s interpretation of the

specification requirements and are not endorsed by OCR. OCR recommends that a range of teaching and learning resources are used in preparing learners for assessment. OCR has not paid for the production of this resource, nor does OCR receive any royalties from its sale. For more information about the endorsement process, please visit the OCR website, www.ocr.org.uk.