Binary Trees
What is the second property of a binary tree ? Given the height of a tree you can work out maximum number of nodes ?
Given the height of a tree you can work out the maximum number of nodes possible in the entire tree 2^h -1 where h is the height. height - total number of levels which means you count the 0 for the root node a well. because you count 0 when calculating the height, you take away 1 hence maximum number of nodes possible in the entire tree 2^h -1
Array representation of a binary tree. How is Nodes stored in an array/list and what index corresponds to what node ?
If a node is numbered [k], then data for that node is stored in the Kth index of this list
What is The definition of a Binary Tree ?
In a Binary tree a node cannot have more than 2 Child nodes.
What is the path length of a tree ?
Level number of that node = to path length of that node
What is the first property of a binary tree ? Maximum number of nodes possible at a level is -
Whatever level you're on, The maximum number of nodes possible in that level, is that level say i to the power of 2 so 2^I levels start at 0 - root node
Given a node stored at Index k then where are the other nodes stored relative to its position ?
if a Node is stored at index k of the list then its left child will be stored at index 2k etc
How to represent this binary tree in a List/array ?
we consider it as a complete binary tree with some missing nodes In the list we leave the indexes empty where there should be a missing node present and fill in the rest