ArticleslgStudy

computer science

X + Y sorting

X + Y sorting is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand X + Y sorting rather than just read about it. In short: In computer science, X + Y sorting is the problem of sorting pairs of numbers by their sums. Applications of the problem include transit fare minimisation, VLSI design, and sparse polynomial multiplication.

X + Y sorting — main illustration
X + Y sorting — illustration

Key takeaways

  • X + Y sorting belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect X + Y sorting to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of X + Y sorting from memory before moving on to harder problems.

Reference excerpt

In computer science, X + Y sorting is the problem of sorting pairs of numbers by their sums. Applications of the problem include transit fare minimisation, VLSI design, and sparse polynomial multiplication. As with comparison sorting and integer sorting more generally, algorithms for this problem can be based only on comparisons of these sums, or on other operations that work only when the inputs are small integers. It is unknown whether this problem has a comparison-based solution whose running time is asymptotically faster than sorting an unstructured list of equally many items. Therefore, research on the problem has focused on two approaches to settle the question of whether such an improvement is possible: the development of algorithms that improve on unstructured sorting in their number of comparisons rather than in their total running time, and lower bounds for the number of comparisons based on counting cells in subdivisions of high-dimensional spaces. Both approaches are historically tied together, in that the first algorithms that used few comparisons were based on the weakness of the cell-counting lower bounds.

Problem statement and history The input to the X+Y sorting problem consists of two finite collections of numbers X and Y, of the same length. The problem's output is the collection of all pairs of a number from X and a number from Y, arranged into sorted order by the sum of each pair. As a small example, for the inputs X={1,2,9} and Y={0,4,9}, the output should be the list of pairs(1,0),(2,0),(1,4),(2,4),(9,0),(1,9),(2,9),(9,4),(9,9)of one element from X and one element from Y, listed in sorted order by their sums of pairs1,2,5,6,9,10,11,13,18.One way to solve the problem would be to construct the pairs to be sorted (the Cartesian product of the two collections) and use these pairs as input to a standard comparison sorting algorithm such as merge sort or heapsort. When the inputs have length n, they form n2 pairs, and the time to sort the pairs in this way is O(n2log⁡n). In terms of its big O notation, this method is the fastest known algorithm for X+Y sorting. Whether a faster algorithm exists is an open problem, posed by Elwyn Berlekamp prior to 1975. A variant of the problem sorts the sumset, the set of sums of pairs, with duplicate sums condensed to a single value. For this variant, the size of the sumset may be significantly smaller than n2, and output-sensitive algorithms for constructing it have been investigated.

Applications Steven Skiena recounts a practical application in transit fare minimisation, an instance of the shortest path problem: find the cheapest two-hop airplane ticket between two given cities, from an input that describes both the cost of each hop and which pairs of hops may be combined into a single ticket. Skiena's solution consists of sorting pairs of hops by their total cost as an instance of the X+Y sorting problem, and then testing the resulting pairs in this sorted order until finding one that is allowed. To generate the sorted pairs in this order, Skiena uses a priority queue of pairs, initially containing only a single pair, the one consisting of the two cheapest hops. Then, when a pair (x,y) is removed from the queue and found to be disallowed, two more pairs are added, with one of these two pairs combining x with the next hop after y in a sorted list of the hops to the destination, and the other pair combining y with the next hop after x in a sorted list of hops from the start. In this way, each successive pair can be found in logarithmic time, and only the pairs up to the first allowable one need to be sorted. X+Y sorting is the most expensive subroutine in an algorithm for a problem in VLSI design, in which one must place two subunits of a VLSI circuit side-by-side along a communications channel in order to minimize the width of the channel needed to route pairs of wires from one subunit to the other. As one subunit is continuously shifted relative to the other, the channel width only changes at discrete positions where the ends of two wires line up with each other, and finding the sorted ordering of these positions in order to compute the sequence of changes to the width can be performed by X+Y sorting. If this sorting problem could be sped up, it would also speed up this VLSI design task. Another application involves polynomial multiplication for polynomials of a single variable that may have many fewer terms than their degrees. The product of two polynomials can be expressed as a sum of products of pairs of terms, one from each polynomial, and placing these term-by-term products into degree order amounts to sorting them by the sum of degrees. For example, the instance of X+Y sorting with n=3 given as an example above corresponds to the multiplication of two three-term polynomials to produce a nine-term polynomial: (x+x2+x9)(1+x4+x9)=x+x2+x5+x6+x9+x10+x11+x13+x18. The degrees are always integers, so integer-based algorithms for X+Y sorting may be applied. However, for polynomials whose number of terms is comparable to their degree, FFT-based polynomial multiplication algorithms may be significantly more efficient than term-by-term multiplication.

… excerpt ends here. Continue reading the full article.

Illustrations

X + Y sorting: Geometric visualization of the X+Y sorting problem. The input sets X and Y are represented by the sets of vertical and horizontal black lines (respectively), and the goal of the problem is to sort the crossing points by the positions of the red diagonal lines through them.
Geometric visualization of the X+Y sorting problem. The input sets X and Y are represented by the sets of vertical and horizontal black lines (respectively), and the goal of the problem is to sort the crossing points by the positions of the red diagonal lines through them.

Worked examples

Example 1 — a first encounter with X + Y sorting

Start with the simplest possible case. Write down what X + Y sorting claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to X + Y sorting before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about X + Y sorting ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of X + Y sorting

In research
X + Y sorting appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses X + Y sorting in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
X + Y sorting is common in secondary-school and first-year university syllabi. It links to neighbouring topics Sorting algorithms, Unsolved problems in computer science, so understanding it makes those chapters shorter.
In everyday life
Look for X + Y sorting outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “X + Y sorting” →

How to study X + Y sorting in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what X + Y sorting means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain X + Y sorting out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is X + Y sorting in simple terms?

In computer science, X + Y sorting is the problem of sorting pairs of numbers by their sums. Applications of the problem include transit fare minimisation, VLSI design, and sparse polynomial multiplication.

Why does X + Y sorting matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study X + Y sorting?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on X + Y sorting.

Tags

  • Sorting algorithms
  • Unsolved problems in computer science

Keep exploring