I have to program several different types of binary trees. However, I’m not allowed to use utils such as arrays or collections. It is suggested to build my own array, should there be a need for it. The problem is, I don’t even know where to start with this. How could I build, say, a 2D array?
I have to program several different types of binary trees. However, I’m not allowed
Share
You will have to manually create a linked list or tree through the creation of objects which each contain a pointer to the next object in the list or tree. This is an exercise that we did many times in our data structures class when I was in school. Understanding how to keep the list or tree intact through inserts and deletes is a useful exercise.
public class ListNode<T> { private T payload; private ListNode<T> nextNode; } public class TreeNode<T> { private T payload; private TreeNode<T> leftChild, rightChild; }