MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayLet's assume you have a number of calculations to perform, that depend on each other. E.g. 'A' can be calculated, once the outcome of 'B' is known. And 'C' depends on the results of 'A' and 'D'. 'D' depends on 'A'. 'E' depends on all others. Find the right order of the calculations, needed to get all the results. Assume that only one calculation can be done at a time.

The dependencies of the calculations on each other is expressed in a matrix, where each row and column corresponds to a specific calculation.

A B C D E A 0 1 0 0 0 B 0 0 0 0 0 C 1 0 0 1 0 D 1 0 0 0 0 E 1 1 1 1 0

A '1' indicates that the calculation on that row depends on the one mentioned at the top of that column.

In matrix terms, re-order the rows and columns (the same operation applies to both) such that the upper-right triangle, above the diagonal, only contains zeros.

B A D C E B 0 0 0 0 0 A 1 0 0 0 0 D 0 1 0 0 0 C 0 1 1 0 0 E 1 1 1 1 0

Return the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. In this example:

[ 2 1 4 3 5 ]

You may assume that all calculations can be executed, in some order or another.

9 correct solutions
18 incorrect solutions

Last solution submitted on Jun 12, 2014

2 Comments