ArticleslgStudy

mathematics

Largest differencing method

Largest differencing method is a mathematics 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 Largest differencing method rather than just read about it. In short: In computer science, the largest differencing method is an algorithm for solving the partition problem and the multiway number partitioning. It is also called the Karmarkar–Karp algorithm after its inventors, Narendra Karmarkar and Richard M.

Key takeaways

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

Reference excerpt

In computer science, the largest differencing method is an algorithm for solving the partition problem and the multiway number partitioning. It is also called the Karmarkar–Karp algorithm after its inventors, Narendra Karmarkar and Richard M. Karp. It is often abbreviated as LDM.

The algorithm The input to the algorithm is a set S of numbers, and a parameter k. The required output is a partition of S into k subsets, such that the sums in the subsets are as nearly equal as possible. The main steps of the algorithm are:

Order the numbers from large to small. Replace the largest and second-largest numbers by their difference. If two or more numbers remain, return to step 1. Using backtracking, compute the partition.

Two-way partitioning For k=2, the main step (2) works as follows.

Take the two largest numbers in S, remove them from S, and insert their difference (this represents a decision to put each of these numbers in a different subset). Proceed in this way until a single number remains. This single number is the difference in sums between the two subsets. For example, if S = {8,7,6,5,4}, then the resulting difference-sets are {6,5,4,1} after taking out the largest two numbers {8,7} and inserting the difference 8-7=1 back; Repeat the steps and then we have {4,1,1}, then {3,1} then {2}. Step 3 constructs the subsets in the partition by backtracking. The last step corresponds to {2},{}. Then 2 is replaced by 3 in one set and 1 in the other set: {3},{1}, then {4},{1,1}, then {4,5}, {1,6}, then {4,7,5}, {8,6}, where the sum-difference is indeed 2. The runtime complexity of this algorithm is dominated by the step 1 (sorting), which takes O(n log n). Note that this partition is not optimal: in the partition {8,7}, {6,5,4} the sum-difference is 0. However, there is evidence that it provides a "good" partition:

If the numbers are uniformly distributed in [0,1], then the expected difference between the two sums is n−Θ(log⁡(n))). This also implies that the expected ratio between the maximum sum and the optimal maximum sum is 1+n−Θ(log⁡(n))) . When there are at most 4 items, LDM returns the optimal partition. LDM always returns a partition in which the largest sum is at most 7/6 times the optimum. This is tight when there are 5 or more items. On random instances, this approximate algorithm performs much better than greedy number partitioning. However, it is still bad for instances where the numbers are exponential in the size of the set.

Multi-way partitioning For any k ≥ 2, the algorithm can be generalized in the following way.

Initially, for each number i in S, construct a k-tuple of subsets, in which one subset is {i} and the other k-1 subsets are empty. In each iteration, select two k-tuples A and B in which the difference between the maximum and minimum sum is largest, and combine them in reverse order of sizes, i.e.: smallest subset in A with largest subset in B, second-smallest in A with second-largest in B, etc. Proceed in this way until a single partition remains. Examples:

If S = {8,7,6,5,4} and k=2, then the initial partitions are ({8},{}), ({7},{}), ({6},{}), ({5},{}), ({4},{}). After the first step we get ({6},{}), ({5},{}), ({4},{}), ({8},{7}). Then ({4},{}), ({8},{7}), ({6},{5}). Then ({4,7},{8}), ({6},{5}), and finally ({4,7,5},{8,6}), where the sum-difference is 2; this is the same partition as described above. If S = {8,7,6,5,4} and k=3, then the initial partitions are ({8},{},{}), ({7},{},{}), ({6},{},{}), ({5},{},{}), ({4},{},{}). After the first step we get ({8},{7},{}), ({6},{},{}), ({5},{},{}), ({4},{},{}). Then ({5},{},{}), ({4},{},{}), ({8},{7},{6}). Then ({5},{4},{}), ({8},{7},{6}), and finally ({5,6},{4,7},{8}), where the sum-difference is 3. If S = {5,5,5,4,4,3,3,1} and k=3, then after 7 iterations we get the partition ({4,5},{1,4,5},{3,3,5}). This solution is not optimal; a better partitioning is provided by the grouping ({5,5},{3,3,4},{1,4,5}). There is evidence for the good performance of LDM:

Simulation experiments show that, when the numbers are uniformly random in [0,1], LDM always performs better (i.e., produces a partition with a smaller largest sum) than greedy number partitioning. It performs better than the multifit algorithm when the number of items n is sufficiently large. When the numbers are uniformly random in [o, o+1], from some o>0, the performance of LDM remains stable, while the performance of multifit becomes worse as o increases. For o>0.2, LDM performs better. Let f* be the optimal largest sum. If all numbers are larger than f*/3, then LDM returns the optimal solution. Otherwise, LDM returns a solution in which the difference between largest and smallest sum is at most the largest number which is at most f*/3. When there are at most k+2 items, LDM is optimal. When the number of items n is between k+2 and 2k, the largest sum in the LDM partition is at most 43−13(n−k−1) times the optimum, In all cases, the largest sum in the LDM partition is at most 43−13k times the optimum, and there are instances in which it is at least 43−13(k−1) times the optimum. For two-way partitioning, when inputs are uniformly-distributed random variables, the expected difference between largest and smallest sum is n−Θ(log⁡n).

Balanced two-way partitioning Several variants of LDM were developed for the balanced number partitioning problem, in which all subsets must have the same cardinality (up to 1). PDM (Paired Differencing Method) works as follows.

Order the numbers from large to small. Replace numbers #1 and #2 by their difference; #3 and #4 by their difference; etc. If two or more numbers remain, return to step 1. Using backtracking, compute the partition. PDM has average properties worse than LDM. For two-way partitioning, when inputs are uniformly-distributed random variables, the expected difference between largest and smallest sum is Θ(1/n). RLDM (Restricted Largest Differencing Method) works as follows.

Order the numbers from large to small. Replace numbers #1 and #2 by their difference; #3 and #4 by their difference; etc. Sort the list of n/2 differences from large to small. Assign each pair in turn to different sets: the largest in the pair to the set with the smallest sum, and the smallest in the pair to the set with the largest sum. For two-way partitioning, when inputs are uniformly-distributed random variables, the expected difference between largest and smallest sum is O(log⁡n/n2). BLDM (Balanced Largest Differencing Method) works as follows.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Largest differencing method

Start with the simplest possible case. Write down what Largest differencing method claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, 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 Largest differencing method 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 Largest differencing method 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 Largest differencing method

In research
Largest differencing method appears in mathematics 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 Largest differencing method 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
Largest differencing method is common in secondary-school and first-year university syllabi. It links to neighbouring topics Number partitioning, so understanding it makes those chapters shorter.
In everyday life
Look for Largest differencing method 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 “Largest differencing method” →

How to study Largest differencing method in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Largest differencing method 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 Largest differencing method out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Largest differencing method in simple terms?

In computer science, the largest differencing method is an algorithm for solving the partition problem and the multiway number partitioning. It is also called the Karmarkar–Karp algorithm after its inventors, Narendra Karmarkar and Richard M.

Why does Largest differencing method matter?

Because it connects several mathematics 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 Largest differencing method?

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 Largest differencing method.

Tags

  • Number partitioning

Keep exploring