I've been reading through The Art of Computer Programming, and though it has its moments of higher maths that I just can't get, some exercises have been fun to do.
After I've done one of them I go over to the answer, see if I did better or worse than what the book suggests (usually worse), But I don't get what the answer for the current one I'm on is trying to convey at all.
The book's question and proposed solution can be found here
What I've understood is that t
may be the number of 'missing' elements or may be a general constant, but what I really don't understand is the seemingly arbitrary instruction to sort them based on their components, which to me looks like spinning your wheels in place since at first glance it doesn't get you closer to the original order. And the decision (among others) to replace one part of the paired names with a number ( file G contains all pairs (i,xi) for n−t < i ≤ n).
So my question is, simply, How do I extract an algorithm from this answer?
Bit of a clarification:
I understand what it aims to do, and how I would go into translating it into C++. What I do not understand is why I am supposed to sort the copies of the input file, and if so which criteria do I sort by, as well as the reasons to changing one side of the pairs to a number.