Package adt.tree

Examples of adt.tree.TreeNode


import adt.tree.TreeNode;

public class Q023_Foldable_Binary_Trees {

  public static void main(String[] args) {
    TreeNode root = Tree.tree1();
    boolean res = isFoldable(root);
    System.out.println(res);
  }
View Full Code Here


import adt.tree.TreeNode;

public class Q067_Extract_Leaves_of_a_Binary_Tree_in_a_Doubly_Linked_List {

  public static void main(String[] args) {
    TreeNode root = Tree.tree11();
    root = extractLeafList(root);
    root.print();
  }
View Full Code Here

import adt.tree.TreeNode;

public class Q019_Print_all_paths_which_sum_to_a_given_value {

  public static void main(String[] args) {
    TreeNode root = Tree.bst2();
    findSum(root, 50);
  }
View Full Code Here

import adt.tree.TreeNode;

public class Q017_Determine_if_a_binary_tree_is_height_balanced {

  public static void main(String[] args) {
    TreeNode root = Tree.tree2();
    boolean res = isBalanced(root);
    System.out.println(res);
  }
View Full Code Here

import adt.tree.TreeNode;

public class Q048_Two_nodes_of_a_BST_are_swapped_correct_the_BST {

  public static void main(String[] args) {
    TreeNode root = Tree.tree7();
    correctBST(root);
  }
View Full Code Here

import adt.tree.TreeNode;

public class Q002_Calculate_Size_of_a_tree {

  public static void main(String[] args) {
    TreeNode root = Tree.tree1();
    int res = size(root);
    System.out.println(res);
  }
View Full Code Here

import adt.tree.TreeNode;

public class Q006_Convert_a_Binary_Tree_into_its_Mirror_Tree {

  public static void main(String[] args) {
    TreeNode root = Tree.tree1();
    mirror(root);
    root.print();
  }
View Full Code Here

    /* do the subtrees */
    mirror(root.left);
    mirror(root.right);
   
    /* swap the pointers in this node */
    TreeNode tmp = root.left;
    root.left = root.right;
    root.right = tmp;
  }
View Full Code Here

public class Q049A_Construct_Full_Binary_Tree_from_given_preorder_and_postorder_traversals {
 
  public static void main(String[] args) {
    int[] pre = {1, 2, 4, 8, 9, 5, 3, 6, 7};
    int[] post = {8, 9, 4, 5, 2, 6, 7, 3, 1};
    TreeNode root = construct(pre, post, 9);
    root.print();
  }
View Full Code Here

    if (n <= 0) {
      return null;
    }
   
    // pre的第一个就是root node
    TreeNode root = new TreeNode(pre[i]);
   
    if (n == 1) {
      return root;
    }
   
View Full Code Here

TOP

Related Classes of adt.tree.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.