making a binary tree
Hi I want to make a binary tree which is based -level,which means that nodes of first level will be cre开发者_StackOverflow社区ate and then all the nodes of second level will be creat and then all the nodes of third level will be create ,... for making a binary tree like above ,I used a list(data structure) I want to know that JVM can remember the order of nodes or I must use list? thanks
You would need to use a data structure that maintains the links between your elements. If you just had an array and created everything at level 1, then created a second array at level 2, the JVM won't remember for you the order that things were created.
In short, you're likely going to want to use a Linked List for something like that.
精彩评论