Full Tree Decompression

Given a String that represents a Binary Tree, write a method - decompressTree that decompresses that tree (reconstructs the tree) and returns the root TreeNode. The compression algorithm included traversing the tree level by level, from the left to the right. The TreeNode's data values were appended to the String, delimited by commas. Also, nullTreeNodes were denoted by appending an asterisk - *. The input String denotes the structure of a Full Binary Tree - i.e. a tree that is structurally balanced. However, the reconstructed tree may not be a full tree as the String included * characters, which represent nullTreeNodes.

Note:You can assume that if a Binary Tree contains k levels, the compressed String will contain 2k-1 elements - either numbers or *.

Tokenize the String into a list of Strings - nodesSplit = str.split(",") and create an ArrayList of Integers that holds the data value of the TreeNodes. Once you have this list, iterate over this list as you construct the tree using a Queue.

1) Create an ArrayList of Integers that holds the data value of the Tree's nodes.

2) Create a Queue that will hold TreeNodes as you move across the list.

3) Create a new TreeNode from the first index item of the list and add it to the Queue.

3) In every iteration of the loop, .poll() a TreeNode from the Queue. If the TreeNode is null, increment the loop index by 2 (as we want to skip the next two items in the list, which will be *)

4) Otherwise, depending on whether the left and right children of this node exist, create them and add them to the TreeNode as well as to the Queue. Increment the index by 2 to skip over the next 2 nodes.