02volume Network
02volume Network
class TreeNode {
String data;
ArrayList<TreeNode> children;
- BST, Heap tree, AVL, red black trees, syntax tree is all **binary tree** $\
Rightarrow$ help solve Huffman problem, heap priority problem, expression parsing
problem
- Full binary tree: node can't have a single child (2 children or 0 child)
- Perfect binary tree: all non leaf node have 2 children
- Balanced binary tree: all leaf nodes are located at the same distance from the
root node
```Java
public class BinaryTree {
String[] arr;
int lastUsedIndex;
postOrder(2 * index);
postOrder(2 * index + 1);
System.out.print(arr[index] + " ");
}
inOrder(index * 2);
System.out.print(arr[index] + " ");
inOrder(index * 2 + 1);
return -1;
}
```