tree algorithm example

Solutions on MaxInterview for tree algorithm example by the best coders in the world

showing results for - "tree algorithm example"
Faith
07 Sep 2018
1public class Tree<T> {
2    private Node<T> root;
3
4    public Tree(T rootData) {
5        root = new Node<T>();
6        root.data = rootData;
7        root.children = new ArrayList<Node<T>>();
8    }
9
10    public static class Node<T> {
11        private T data;
12        private Node<T> parent;
13        private List<Node<T>> children;
14    }
15}
16