From the course: Data Structures in JavaScript: Trees and Graphs
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
What is a binary tree?
From the course: Data Structures in JavaScript: Trees and Graphs
What is a binary tree?
- [Instructor] What is a binary tree? A binary tree is made of nodes. Each node has at most two children and some data. The children are called the left and right child. Binary trees do not inherently order data in a specific way. However, a particular type of binary tree called a binary search tree maintains a specific ordering of data. We'll get more into that later. Like tree data structures, the binary tree contains a root node, the topmost node of the tree. As stated before, each node can have a data value and an edge to at most two children, the left and right. In this example, the root node A has an edge to its left child B and an edge to its right child C. A is also considered the parent node of B and C. B has an edge to its left child D and an edge to its right child E. C does not have an edge to a left child and an edge to its right child F. Technically C has a pointer to a null value for its left. Remember that a binary tree consists of nodes with at most two children and…