Types of Trees
In this chapter, we are going to discuss N-ary and Balanced Trees.
We'll cover the following
Introduction
Trees being advanced data structures, offer a wide variety of types to provide an efficient solution, specific to a particular use. Trees are extensively used in Artificial Intelligence and complex algorithms to provide an efficient storage mechanism for problem-solving. Based on the structure, height, and other features like time/space complexity, there are different types of trees.
The most commonly used types are listed below:
- N-ary Tree
- Balanced Tree
- Binary Tree
- BinarySearchTree
- AVL Tree
- Red-Black Tree
- 2-3 Tree
Let’s take a look at N-ary and Balanced Trees in this lesson and the other types later in the chapter.
N-ary Tree
In N-ary trees, each node can have child nodes anywhere from 0 to N. So if it’s a 2-ary tree, commonly known as a Binary Tree, it can have a max. of 0-2 child nodes. Can you guess the value of N in the figure shown below?
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.