JAVA: binary trees

别等时光非礼了梦想. 提交于 2019-12-05 10:09:18

The assignment statements

root.left = lefty;
root.right = righty;

are not allowed on the class level. You can achieve the effect you want changing this line

Node root = new Node("ROOT");

to this

Node root = new Node("ROOT", lefty, righty);

which takes advantage of your three-argument constructor.

However, you may want to reconsider the placement of root, lefty and righty. They are probably intended in the bTree class. Also, there is a convention that encourages naming class capitalizing the first letter of each word, e.g. BinaryTree.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!