首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Java 实现二叉树的构建以及3种遍历方法

    null;               data = newData;           }       }   public void createBinTree() {           nodeList...(parentIndex).leftChild = nodeList                       .get(parentIndex * 2 + 1);   // 右孩子               ...nodeList.get(parentIndex).rightChild = nodeList                       .get(parentIndex * 2 + 2);           ...   if (array.length % 2 == 1) {               nodeList.get(lastParentIndex).rightChild = nodeList  ...中第0个索引处的值即为根节点           Node root = nodeList.get(0);           System.out.println("先序遍历:");

    1.7K10
    领券