ArticleslgStudy

mathematics

Ershov number

Ershov number 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 Ershov number rather than just read about it. In short: Ershov numbers, named after Andrey Petrovich Yershov, are used in code optimization to minimize the amount of register allocations. Ershov numbers can be used in methods to optimally select registers when there is only one expression in a code block.

Key takeaways

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

Reference excerpt

Ershov numbers, named after Andrey Petrovich Yershov, are used in code optimization to minimize the amount of register allocations. Ershov numbers can be used in methods to optimally select registers when there is only one expression in a code block. Given an expression E = E1 op E2 the goal is to generate code so as to either minimize the number of registers used, or, if an insufficient number of registers is available, to minimize the number of nonregister temporaries required.

Definition The Ershov number n of a node in a given expression tree is defined as follows:

Every leaf has n=1. For a node with one child, n is the same as the child's. For a node with two children with Ershov numbers n1 and n2 , n is defined as: n={max⁡(n1,n2)if n1≠n2,n1+1if n1=n2. The Ershov number of a node represents the minimum number of registers required to evaluate the subexpression whose root is that node. The idea is that we evaluate the child with the larger Ershov number first, then the other child, then perform the operation at the root.

Example Suppose we have an expression tree with a '+' operation at the root, and the left and right subtrees have Ershov numbers of 3 and 4, respectively. The Ershov number of this node is 4, so we should be able to generate code for the expression using 4 registers.

Generate code to evaluate the right child using registers r1, r2, r3, and r4. Place the result in r1. Generate code to evaluate the left child using registers r2, r3, and r4. Place the result in r2. Issue the instruction ADD r1, r1, r2, which adds r1 and r2 and stores the result in r1.

Code generation The general procedure for generating code using a minimal number of loads and stores from memory is as follows:

Generate code for the child with the largest Ershov number first Issue an instruction to store the result in a temporary register, or, if none is available, a temporary location in memory Generate code for the child with the smaller Ershov number Issue an instruction to load the temporary variable back into a register Issue an instruction to perform the operation at the root In the ideal case, if there are n registers and the first subexpression requires n registers and the next subexpression requires n - 1 registers, a single register can be used to store the result of the first expression, and there will still be n - 1 registers available to compute the next subexpression, therefore requiring no loads or stores from memory at all. If the Ershov number of the root of the expression tree is greater than the number of registers available, the Ershov number can also be used to determine the amount of additional temporary memory space required, for example on the stack.

See also Strahler number, the minimum number of registers needed to evaluate an expression without any external storage Sethi–Ullman algorithm, basically the same concept

References

Worked examples

Example 1 — a first encounter with Ershov number

Start with the simplest possible case. Write down what Ershov number 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 Ershov number 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 Ershov number 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 Ershov number

In research
Ershov number 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 Ershov number 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
Ershov number is common in secondary-school and first-year university syllabi. It links to neighbouring topics Software optimization, Syntax, so understanding it makes those chapters shorter.
In everyday life
Look for Ershov number 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 “Ershov number” →

How to study Ershov number in 20 minutes

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

Frequently asked questions

What is Ershov number in simple terms?

Ershov numbers, named after Andrey Petrovich Yershov, are used in code optimization to minimize the amount of register allocations. Ershov numbers can be used in methods to optimally select registers when there is only one expression in a code block.

Why does Ershov number 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 Ershov number?

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 Ershov number.

Tags

  • Software optimization
  • Syntax

Keep exploring