Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

D1 Common word questions

Sorts and Searches

1. Which number is in the correct position after the first pass of a bubble sort?

The biggest number if sorting into ascending

The smallest number if sorting into descending

2. Explain how to complete a bubble sort, sorting numbers into ascending order.

Compare the 1st and 2nd

If the 2nd is smaller, swap, if not keep the same

Then compare the 2nd and 3rd etc.

3. What is the maximum number of passes needed to sort a list of 10 numbers using a bubble sort?

4. What is the maximum number of passes needed to sort a list of n numbers using a bubble sort?

n–1

5. What is the maximum number of iterations needed to sort a list of 10 numbers using a quick sort?

10

6. What is the maximum number of iterations needed to find an item in a list of 10 items using a binary search?

7. What is the maximum number of iterations needed to find an item in a list of 205 items using a binary search?

8
Prims, Kruskals and Dijkstras

1. List the similarities and differences between Prims and Kruskals

Both find the minimum spanning tree

Prims can be used on a distance matrix but Kruskals can’t

Prims grows as a connected tree but Kruskals grows randomly

Prims you add new nodes, Kruskals you add new arcs

Kruskals you have to check for cycles, Prims you don’t

Kruskals you can add given arcs on to start, but Prims you can’t.

2. If a network has 7 nodes, what is the minimum number of arcs that are needed to make a spanning tree
connecting all the nodes?

3. If a network has N nodes, what is the minimum number of arcs that are needed to make a spanning tree
connecting all the nodes?

N–1

4. In a network of towns, town A and B have already been connected. Would you use Kruskals or Prims to find the
minimum spanning tree including the arc AB. Explain how you would use your chosen algorithm.

Kruskals, add the given arcs on first, then continue as normal

5. Explain how you obtain the shortest path once you have filled in the numbers in the boxes for Dijkstras’.

Working backwards

Give an example calculation (or all of them to be sure!)

Eg. From F to E: 5 – 3 = 2
Chinese Postman/Route Inspection

1. If the question states ‘use the route inspection algorithm’, what does this mean?

All nodes must be made even

2. If you are allowed to start and finish at different nodes, what does this mean about the valencies of the nodes?

2 nodes can be left odd (Semi Eularian)

3. If you can start and finish at different nodes, explain why you should start at a node with odd valency.

If you start at an odd node, then you must then finish at the other odd node in the network (as there are always an
even number of odd nodes).

Therefore this removes the need to join these 2 odd nodes to make the route possible. (If you started somewhere
else you would have to repeat arcs to be able to draw the picture)

This therefore makes your overall route shorter.

4. Explain why a network cannot have an odd number of vertices of odd valency.

Each arc adds 2 on to the total valancy

Therefore the total valency has to be even

Therefore if you have an odd number of nodes with an odd valency, the total would be odd, which is impossible.

5. If the total valency of all the nodes in a network is m, how many arcs are in the network?

m/2
Critical Path

1. State the 2 reasons why dummies may be used in a network.

If two events have the same starting node, to be defined uniquely, they must have different end nodes.

When 2 activities do not rely on the same preceding activities. For example, if one activity depends on A but another
depends on A and B

2. What calculation do you do in order to work out the float for an activity?

Latest finish time – event duration – earliest start time


Linear Programming

1. In every real life problem there are 2 inequalities that apply. What are the 2 inequalities?

x ≥ 0 and y ≥ 0

2. What are the differences and similarities between the objective line method and the vertex testing method?

Both find the optimal point

Objective line you only have to find the coordinate of 1 vertex, whereas in point testing you have to find the
coordinates of all the vertices.

Objective line you do not have to test the points in the Objective Function, whereas in point testing you do.
Matchings

1. Explain when it is necessary to use the matching algorithm twice.

When there are two nodes from each set that are unmatched.

Each iteration of the algorithm only pairs up 1 extra set of nodes.

2. What are the 2 reasons that it may be impossible to get a complete matching?

If 1 person is the only person that can do 2 events

If 2 people can only do 1 event, and that 1 event is the same

3. Explain the difference between a complete matching and a maximal matching.

Complete matching is when all the nodes from one set are paired with all the nodes from another set.

Maximal matching is when the maximum amount of pairings have occurred.

You might also like