SECTION 22 / 24

Compare the same student’s positions in two lists

1 min read
Match by student ID before subtracting positions. The lecture’s ten-student ordering has a mean absolute position difference of 3.
Match by student ID before subtracting positions. The lecture’s ten-student ordering has a mean absolute position difference of 3.
REAL COURSE DATA · BUILD AND UNPACK LISTS

Compare positions in two sorted lists

Follow one occurrence at a time. Choose another input to test empty lists, repeated IDs and different parameters.

Ready

CURRENT RECORD / VALUE

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Predict the next change, then step through the list. The original course records remain unchanged.

Make [ID,Maths] and [ID,Physics] lists, each sorted ascending by its mark. For a student at position i in the Maths list, find the SAME ID in the Physics list at position j. Store [ID,abs(i−j)]. Keeping IDs prevents accidentally comparing different students occupying the same position.

IDMaths positionPhysics positionAbsolute difference
3121
24275
12352
19484
2532
22642
17792
1817
99101
101064

These are the lecture’s ten low-Maths students and its displayed tie order. The differences total 30, so their mean is 30/10 = 3. Student #1 has the largest difference in this example, 7. We use one-based ascending list positions, so low marks appear first. These are not automatically standard competition ranks or average tied ranks.

Equal marks need an explicit tie policy. To reproduce the lecture we retain its shown order, including ties. The all-30 option sorts by mark and uses smaller CardNo first when marks tie. Different tie policies can change position differences. Do not present a tie-dependent position number as an intrinsic rank.

The lecture’s subset was chosen for low Maths marks, not randomly sampled. Its mean difference does not establish a population correlation or prove the same relationship across all students. This exercise demonstrates joining two ordered lists by identity and accumulating a descriptive distance.

Try it yourself

Why use the absolute difference?

Show explained answer

Signed differences can cancel. Absolute differences measure how far apart the positions are regardless of direction.

Try it yourself

If the same ID is fourth in both lists, what is its difference?

Show explained answer

|4−4| = 0. The ID match is essential; comparing two different students at position 4 is a different task.

Try it yourself

Does average distance 3 prove Maths causes Physics performance?

Show explained answer

No. It is a descriptive calculation for the chosen data and tie convention, not a causal conclusion.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑