Week 10 - 11 Flashcards
is composed of nodes with children nodes. The first/top node is called the root node.
A general tree data structure
trees rules
- Node does not reference to there siblings.
- Child nodes pointed to parent.
- Two root nodes.
The top node in a tree.
Root –
A node directly connected to another node when moving away from the root.
Child –
The converse notion of a child.
Parent –
A group of nodes with the same parent.
Siblings –
A node with no children
Leaf –
The connection between one node and another.
Edge –
is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child. This structure is widely used in computer science for various purposes, such as searching, sorting, and hierarchical data organization.
A Binary Tree
always has a root node (the node at the top), which is initialized to null before any element is inserted.
A binary tree
Binary Tree Rules
1.Maximum Number of Children.
Each node can have at most two children.
2.Hierarchy.
The tree starts from a root node.
Each child node can act as a root for its own subtree.
3.Levels.
The root is at level 0.
Its children are at level 1, their children are at level 2, and so on.
4.Height.
The height of a tree is the number of edges on the longest path from the root to a leaf.
5.Leaf Nodes.
Nodes with no children are called leaf nodes.
Each node can have at most two children.
1.Maximum Number of Children.
The tree starts from a root node.
2.Hierarchy.
The root is at level 0.
Its children are at level 1, their children are at level 2, and so on.
3.Levels.
The height of a tree is the number of edges on the longest path from the root to a leaf.
4.Height.