Floyd's algorithm application

A question is this type if and only if it requires applying Floyd's algorithm to find shortest distances between all pairs of vertices, typically with iteration tables.

14 questions · Moderate -0.5

Sort by: Default | Easiest first | Hardest first
OCR MEI D2 2007 June Q3
20 marks Easy -1.2
3 Floyd's algorithm is applied to the following network: \includegraphics[max width=\textwidth, alt={}, center]{483a681e-011a-464f-b7cb-007d894d1516-3_398_394_331_833} At the end of the third iteration of the algorithm the distance and route matrices are as follows:
\cline { 2 - 5 } \multicolumn{1}{c|}{}\(\mathbf { 1 }\)\(\mathbf { 2 }\)\(\mathbf { 3 }\)\(\mathbf { 4 }\)
\(\mathbf { 1 }\)63105
\(\mathbf { 2 }\)3672
\(\mathbf { 3 }\)107141
OCR MEI D2 2008 June Q3
20 marks Moderate -0.5
3 The weights on the network represent distances. \includegraphics[max width=\textwidth, alt={}, center]{88acde67-e22b-478a-9145-48abe931beff-3_401_702_315_683}
    1. Apply Floyd's algorithm to the network to find the complete network of shortest distances, showing that the final matrices are as follows.
      \cline { 2 - 5 } \multicolumn{1}{c|}{}\(\mathbf { 1 }\)\(\mathbf { 2 }\)\(\mathbf { 3 }\)\(\mathbf { 4 }\)
      \(\mathbf { 1 }\)22141123
      \(\mathbf { 2 }\)14281527
      \(\mathbf { 3 }\)11152212
      \(\mathbf { 4 }\)23271224
OCR MEI D2 2008 June Q4
20 marks Standard +0.3
\cline { 2 - 5 } \multicolumn{1}{c|}{}\(\mathbf { 1 }\)\(\mathbf { 2 }\)\(\mathbf { 3 }\)\(\mathbf { 4 }\)
\(\mathbf { 1 }\)0131015
\(\mathbf { 2 }\)1301220
\(\mathbf { 3 }\)101209
\(\mathbf { 4 }\)23271224
\cline { 2 - 5 } \multicolumn{1}{c|}{}\(\mathbf { 1 }\)\(\mathbf { 2 }\)\(\mathbf { 3 }\)\(\mathbf { 4 }\)
\(\mathbf { 1 }\)3233
\(\mathbf { 2 }\)1133
\(\mathbf { 3 }\)1214
\(\mathbf { 4 }\)3333
Draw the complete network of shortest distances.
(ii) Starting at vertex 1, apply the nearest neighbour algorithm to the complete network of shortest distances to find a Hamilton cycle. Give the length of your cycle and interpret it in the original network.
(iii) By temporarily deleting vertex \(\mathbf { 1 }\) and its connecting arcs from the complete network of shortest distances, find a lower bound for the solution to the Travelling Salesperson's Problem in that network. Say what this implies in the original network.
(b) Solve the route inspection problem in the original network, and say how you can be sure that your solution is optimal. 4 A factory's output includes three products. To manufacture a tonne of product \(\mathrm { A } , 3\) tonnes of water are needed. Product B needs 2 tonnes of water per tonne produced, and product C needs 5 tonnes of water per tonne produced. Product A uses 5 hours of labour per tonne produced, product B uses 6 hours and product C uses 2 hours. There are 60 tonnes of water and 50 hours of labour available for tomorrow's production.
(i) Formulate a linear programming problem to maximise production within the given constraints.
(ii) Use the simplex algorithm to solve your LP, pivoting first on your column relating to product C.
(iii) An extra constraint is imposed by a contract to supply at least 8 tonnes of A . Use either two stage simplex or the big M method to solve this revised problem.
OCR MEI D2 2009 June Q4
20 marks Moderate -0.8
4 The diagram shows routes connecting five cities. Lengths are in km . \includegraphics[max width=\textwidth, alt={}, center]{ae8dc840-0c61-4ba5-b082-1f5f3e6c2cef-4_442_995_319_534}
  1. Produce the initial matrices for an application of Floyd's algorithm to find the complete network of shortest distances between the five cities. The following are the distance and route matrices after the third iteration of Floyd's algorithm.
    \cline { 2 - 6 } \multicolumn{1}{c|}{}\(\mathbf { 1 }\)\(\mathbf { 2 }\)\(\mathbf { 3 }\)\(\mathbf { 4 }\)\(\mathbf { 5 }\)
    \(\mathbf { 1 }\)4422421515
    \(\mathbf { 2 }\)224420523
    \(\mathbf { 3 }\)4220402543
    \(\mathbf { 4 }\)155251016
    \(\mathbf { 5 }\)1523431630
OCR MEI D2 2010 June Q2
16 marks Easy -1.2
2 The network is a representation of a show garden. The weights on the arcs give the times in minutes to walk between the six features represented by the vertices, where paths exist. \includegraphics[max width=\textwidth, alt={}, center]{c3a528e4-b5fe-4bff-a77e-e3199bb225a1-3_483_985_342_539}
  1. Why might it be that the time taken to walk from vertex \(\mathbf { 2 }\) to vertex \(\mathbf { 3 }\) via vertex \(\mathbf { 4 }\) is less than the time taken by the direct route, i.e. the route from \(\mathbf { 2 }\) to \(\mathbf { 3 }\) which does not pass through any other vertices? The matrices shown below are the results of the first iteration of Floyd's algorithm when applied to the network.
    \cline { 2 - 7 } \multicolumn{1}{c|}{}\(\mathbf { 1 }\)\(\mathbf { 2 }\)\(\mathbf { 3 }\)\(\mathbf { 4 }\)\(\mathbf { 5 }\)\(\mathbf { 6 }\)
    \(\mathbf { 1 }\)\(\infty\)15\(\infty\)\(\infty\)78
    \(\mathbf { 2 }\)153062623
OCR MEI D2 2010 June Q3
20 marks Moderate -0.5
\(\mathbf { 3 }\) & \(\infty\) & 6 & \(\infty\) & 3 & \(\infty\) & \(\infty\) \hline
OCR MEI D2 2010 June Q4
20 marks Moderate -0.5
\(\mathbf { 4 }\) & \(\infty\) & 2 & 3 & \(\infty\) & 10 & 17
\hline
OCR MEI D2 2010 June Q5
Moderate -0.5
\(\mathbf { 5 }\) & 7 & 6 & \(\infty\) & 10 & 14 & 8
\hline
OCR MEI D2 2016 June Q4
20 marks Standard +0.3
\(\mathbf { 4 }\) & 11 & 11 & 7 & 14 & 14
\hline
Edexcel D1 2022 January Q6
14 marks Moderate -0.8
6.
\includegraphics[max width=\textwidth, alt={}]{765ea64e-d4b8-4f0f-9a43-2619f9db0c18-14_1468_1779_285_143}
ABCDEFGH
A-
B-1424111819
C14-1210152223
D212-291617
E4102-71415
F111597-78
G182216147-1
H1923171581-
\section*{Question 6 continued} (b) \(\_\_\_\_\) (c)
BCDEFGH
B-1424111819
C14-1210152223
D212-291617
E4102-71415
F111597-78
G182216147-1
H1923171581-
\section*{Question 6 continued}
Edexcel FD1 2020 June Q3
9 marks Moderate -0.5
3. \begin{figure}[h]
\includegraphics[alt={},max width=\textwidth]{bd357978-6464-43fd-854f-4188b5408e91-04_387_519_214_774} \captionsetup{labelformat=empty} \caption{Figure 2}
\end{figure} Direct roads between five villages, A, B, C, D and E, are shown in Figure 2. The weight on each arc is the time, in minutes, it takes to travel along the corresponding road. The road from D to C is one-way as indicated by the arrow on the corresponding arc. Floyd's algorithm is to be used to find the complete network of shortest times between the five villages.
  1. Set up initial time and route matrices. The matrices after two iterations of Floyd's algorithm are shown below. \begin{table}[h]
    \captionsetup{labelformat=empty} \caption{Time matrix}
    \cline { 2 - 6 } \multicolumn{1}{c|}{}ABCDE
    A-84718
    B8-31510
    C43-116
    D7151-1
    E181061-
    \end{table} \begin{table}[h]
    \captionsetup{labelformat=empty} \caption{Route matrix}
    \cline { 2 - 6 } \multicolumn{1}{c|}{}ABCDE
    AABCDB
    BABCAE
    CABCAE
    DAACDE
    EBBCDE
    \end{table}
  2. Perform the next two iterations of Floyd's algorithm that follow from the tables above. You should show the time and route matrices after each iteration. The final time matrix after completion of Floyd's algorithm is shown below. \begin{table}[h]
    \captionsetup{labelformat=empty} \caption{Final time matrix}
    \cline { 2 - 6 } \multicolumn{1}{c|}{}ABCDE
    A-7478
    B7-3109
    C43-76
    D541-1
    E6521-
    \end{table}
    1. Use the nearest neighbour algorithm, starting at A , to find a Hamiltonian cycle in the complete network of shortest times.
    2. Find the time taken for this cycle.
    3. Interpret the cycle in terms of the actual villages visited.
Edexcel FD1 2022 June Q3
10 marks Moderate -0.5
3. The initial distance matrix (Table 1) shows the lengths, in metres, of the corridors connecting six classrooms, A, B, C, D, E and F, in a school. For safety reasons, some of the corridors are one-way only. \begin{table}[h]
ABCDEF
A-1232242911
B12-178\(\infty\)\(\infty\)
C3217-412\(\infty\)
D24\(\infty\)4-\(\infty\)13
E\(\infty\)\(\infty\)1218-12
F11\(\infty\)\(\infty\)1312-
\captionsetup{labelformat=empty} \caption{Table 1}
\end{table}
  1. By adding the arcs from vertex A, along with their weights, complete the drawing of this network on Diagram 1 in the answer book. Floyd's algorithm is to be used to find the complete network of shortest distances between the six classrooms. The distance matrix after two iterations of Floyd's algorithm is shown in Table 2. \begin{table}[h]
    ABCDEF
    A-1229202911
    B12-1784123
    C2917-41240
    D24364-5313
    E\(\infty\)\(\infty\)1218-12
    F1123401312-
    \captionsetup{labelformat=empty} \caption{Table 2}
    \end{table}
  2. Perform the next two iterations of Floyd's algorithm that follow from Table 2. You should show the distance matrix after each iteration. The final distance matrix after completion of Floyd's algorithm is shown in Table 3.
    ABCDEF
    A-1224202311
    B12-1282421
    C2817-41217
    D24214-1613
    E23291216-12
    F1123171312-
    \section*{Table 3} Yinka must visit each classroom. He will start and finish at E and wishes to minimise the total distance travelled.
    1. Use the nearest neighbour algorithm, starting at E, to find two Hamiltonian cycles in the completed network of shortest distances.
    2. Find the length of each of the two cycles.
    3. State, with a reason, which of the two cycles provides the better upper bound for the length of Yinka's route.
OCR MEI D2 2006 June Q2
16 marks Standard +0.3
2 Answer this question on the insert provided. Fig. 2 shows a network in which the weights on the arcs represent distances. \begin{figure}[h]
\includegraphics[alt={},max width=\textwidth]{9716cf3f-afa5-44a4-a8cd-f7511449d06b-2_405_497_1046_776} \captionsetup{labelformat=empty} \caption{Fig. 2}
\end{figure}
  1. Apply Floyd's algorithm on the insert provided to find the complete network of shortest distances.
  2. Show how to use your final matrices to find the shortest route from vertex \(\mathbf { 1 }\) to vertex 3, together with the length of that route.
  3. Use the nearest neighbour algorithm, starting at vertex 1, to find a Hamilton cycle in the complete network of shortest distances. Give the corresponding cycle in the original network, together with its length.
OCR Further Discrete 2018 December Q4
13 marks Moderate -0.5
4 An algorithm is represented by the flow diagram below. \includegraphics[max width=\textwidth, alt={}, center]{10ca0bf1-beaa-4460-8f28-08f0e4e44d5c-04_1871_1719_293_173} The algorithm is applied with \(n = 4\) and the table of inputs \(\mathrm { d } ( i , j )\) : $$j = 1 \quad j = 2 \quad j = 3 \quad j = 4$$ $$\begin{aligned} & i = 1 \\ & i = 2 \\ & i = 3 \\ & i = 4 \end{aligned}$$
0352
3043
5401
2310
An incomplete trace through the algorithm is shown below.
\(n\)\(i\)\(j\)\(\mathrm { d } ( i , j )\)A\(t\)\(m\)
4
1
1
1100
1
0
2
3
23
3
5
4
2
42
4
1, 4100
1
2
2
3
23
3
1
31
4
0
The next box to be used is the box 'Let \(i = t\) '.
  1. Complete the trace in the Printed Answer Booklet. The table of inputs represents a weighted matrix for a network, where the weights represent distances.
    1. State how the output of the algorithm relates to the network represented by the matrix.
    2. How can the list A be used in the solution of the travelling salesperson problem on the network represented by the matrix?
    3. Write down a limitation on the distances \(\mathrm { d } ( i , j )\) for this algorithm.
  2. Explain why the algorithm is finite for any table of inputs. Suppose that, for a problem with \(n\) vertices, the run-time for the algorithm is given by \(\alpha D + \beta T\), where \(\alpha\) and \(\beta\) are constants, \(D\) is the number of times that a value of \(\mathrm { d } ( i , j )\) is looked up and \(T\) is the number of times that \(t\) is updated.
  3. Show how this means that the algorithm has \(\mathrm { O } \left( n ^ { 2 } \right)\) complexity. A computer takes 3 seconds to run the algorithm for a problem with \(n = 35\).
  4. Use the complexity to calculate an approximate run-time for a problem with \(n = 100\). The run-time using a second algorithm has \(\mathrm { O } ( n ! )\) complexity.
    A computer takes 2.8 seconds to run the second algorithm for a problem with \(n = 35\).
  5. Without performing any further calculations, give a reason why the first algorithm is likely to be more efficient than the second for a problem with \(n = 100\).