ArticleslgStudy

computer science

M-ary tree

M-ary tree 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 M-ary tree rather than just read about it. In short: In graph theory, an m-ary tree (for nonnegative integers m) (also known as n-ary, k-ary, k-way or generic tree) is an arborescence (or, for some authors, an ordered tree) in which each node has no more than m children. A binary tree is an important case where m = 2; similarly, a ternary tree is one where m = 3.

M-ary tree — main illustration
M-ary tree — illustration

Key takeaways

  • M-ary tree 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 M-ary tree to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of M-ary tree from memory before moving on to harder problems.

Reference excerpt

In graph theory, an m-ary tree (for nonnegative integers m) (also known as n-ary, k-ary, k-way or generic tree) is an arborescence (or, for some authors, an ordered tree) in which each node has no more than m children. A binary tree is an important case where m = 2; similarly, a ternary tree is one where m = 3.

Types of m-ary trees A full m-ary tree is an m-ary tree where within each level every node has 0 or m children. A complete m-ary tree (or, less commonly, a perfect m-ary tree) is a full m-ary tree in which all leaf nodes are at the same depth.

Properties of m-ary trees For an m-ary tree with height h, the upper bound for the maximum number of leaves is m h {\displaystyle m^{h}} . The height h of an m-ary tree does not include the root node, with a tree containing only a root node having a height of 0. The height of a tree is equal to the maximum depth D of any node in the tree. The total number of nodes N {\displaystyle N} in a complete m-ary tree is ∑ i = 0 h m i = m h + 1 − 1 m − 1 {\textstyle \sum _{i=0}^{h}m^{i}={\frac {m^{h+1}-1}{m-1}}} , while the height h is

m h + 1 − 1 m − 1 ≥ N > m h − 1 m − 1 m h + 1 ≥ ( m − 1 ) ⋅ N + 1 > m h h + 1 ≥ log m ⁡ ( ( m − 1 ) ⋅ N + 1 ) > h h ≥ ⌈ log m ⁡ ( ( m − 1 ) ⋅ N + 1 ) − 1 ⌉ . {\displaystyle {\begin{aligned}&{\frac {m^{h+1}-1}{m-1}}\geq N>{\frac {m^{h}-1}{m-1}}\\[8pt]&m^{h+1}\geq (m-1)\cdot N+1>m^{h}\\[8pt]&h+1\geq \log _{m}\left((m-1)\cdot N+1\right)>h\\[8pt]&h\geq \left\lceil \log _{m}((m-1)\cdot N+1)-1\right\rceil .\end{aligned}}} By the definition of Big-Ω, the maximum depth

D = h ≥ ⌈ log m ⁡ ( ( m − 1 ) ⋅ N + 1 ) − 1 ⌉ = O ( log m ⁡ n ) = O ( log ⁡ n / log ⁡ m ) . {\displaystyle D=h\geq \left\lceil \log _{m}((m-1)\cdot N+1)-1\right\rceil =O(\log _{m}n)=O(\log n/\log m).}

… excerpt ends here. Continue reading the full article.

Illustrations

M-ary tree: An example of a m-ary tree with m=5
An example of a m-ary tree with m=5
M-ary tree: An example of conversion of a m-ary tree with m=6 to a binary tree.
An example of conversion of a m-ary tree with m=6 to a binary tree.
M-ary tree: An example of storing a m-ary tree with m=3 in an array
An example of storing a m-ary tree with m=3 in an array
M-ary tree: Pointer-based implementation of m-ary tree where m=4.
Pointer-based implementation of m-ary tree where m=4.
M-ary tree: 3-ary tree with bit sequence of 1110000100010001000 and Simple Zero Sequence of 004433
3-ary tree with bit sequence of 1110000100010001000 and Simple Zero Sequence of 004433

Worked examples

Example 1 — a first encounter with M-ary tree

Start with the simplest possible case. Write down what M-ary tree 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 M-ary tree 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 M-ary tree 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 M-ary tree

In research
M-ary tree 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 M-ary tree 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
M-ary tree is common in secondary-school and first-year university syllabi. It links to neighbouring topics Trees (data structures), Trees (graph theory), so understanding it makes those chapters shorter.
In everyday life
Look for M-ary tree 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.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study M-ary tree in 20 minutes

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

Frequently asked questions

What is M-ary tree in simple terms?

In graph theory, an m-ary tree (for nonnegative integers m) (also known as n-ary, k-ary, k-way or generic tree) is an arborescence (or, for some authors, an ordered tree) in which each node has no more than m children. A binary tree is an important case where m = 2; similarly, a ternary tree is one…

Why does M-ary tree 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 M-ary tree?

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 M-ary tree.

Tags

  • Trees (data structures)
  • Trees (graph theory)

Keep exploring