- Related Questions & Answers
- k-ary tree in Data Structure
- Encode N-ary Tree to Binary Tree in C++
- Mirror of n-ary Tree in C++
- N-ary Tree Preorder Traversal in C++
- N-ary Tree Level Order Traversal in C++
- Serialize and Deserialize N-ary Tree in C++
- Depth of an N-Ary tree in C++?
- Even size subtree in n-ary tree in C++
- Depth of an N-Ary tree in C++ Program
- Preorder Traversal of N-ary Tree Without Recursion in C++
- Construct the full k-ary tree from its preorder traversal in C++
- Print all leaf nodes of an n-ary tree using DFS in C++
- N-ary Relationship in Database
- Count of numbers satisfying m + sum(m) + sum(sum(m)) = N in C++
- M-Coloring Problem

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

An m-ary tree in computer science is defined as a collection of nodes normally represented hierarchically in the following manner.

- The tree is started at the root node.
- Each node of the tree maintains a list of pointers to its child nodes.
- The number of child nodes is less than or equal to m.

A typical representation of m-ary tree implements an array of m references (or pointers) to store children (Note that m is an upper bound on number of children).

An m-way search tree

a. is empty or

b. consists of a root containing b (1<=b<m) keys, kb, and a set of sub-trees, Ta, (a = 0..b), such that

- if k is a key in T0, then k <= k1
- if k is a key in Ta (0<a<b), then ka <= k <= ka+1
- if k is a key in Tb, then k > kb and
- all Ta are nonempty m-way search trees or all Ta are empty

Image of m-ary Tree

The height of a complete m-ary tree associated with n nodes is ceiling(log_{m}n).

A B-tree of order m is an m-way tree in which

a. all leaves should be on the same level and

b. all nodes except for the root and the leaves have minimum m/2 children and maximum m children. The root has minimum 2 children and maximum m children.

Advertisements