ConcurrentModificationException with ArrayList
I am building a binarytree ADT for storing a dictionary. My underlying data structure is an arraylist, which is a global in my binarytree class.
My algorithm to build the tree works something like this:
The problem is that I always get the ConcurrentModificationException ( I tried to post the URL here ).
Take an ArrayList
take the middle element and set it as the root of the tree
split the tree at that middle element and set the left and right pointer of the root to the left and right subtrees.
recursively call this method, adding the middle elements to the global ArrayList
My question is, how can I modify a node's (constructed in my "node" class) pointers without getting this problem?
(I could swear this whole project would have taken me 1 hour tops in python. I just spend all my time with these errors.)