forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb8a52f
commit a0ebef1
Showing
1 changed file
with
30 additions
and
23 deletions.
There are no files selected for viewing
53 changes: 30 additions & 23 deletions
53
group16/1325756593/src/com/dong/week1/BinaryTreeNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,39 @@ | ||
package com.dong.week1; | ||
|
||
public class BinaryTreeNode { | ||
private TreeNode node; | ||
|
||
private static class TreeNode{ | ||
private int key=0; | ||
private TreeNode leftChild=null; | ||
private TreeNode rightChild=null; | ||
|
||
public TreeNode(){} | ||
|
||
/** | ||
* @param key ²ãÐò±àÂë | ||
* @param data Êý¾ÝÓò | ||
*/ | ||
public TreeNode(int key){ | ||
this.key=key; | ||
this.leftChild=null; | ||
this.rightChild=null; | ||
} | ||
|
||
|
||
} | ||
|
||
private Object data; | ||
private BinaryTreeNode left; | ||
private BinaryTreeNode right; | ||
|
||
public Object getData() { | ||
return data; | ||
} | ||
public void setData(Object data) { | ||
this.data = data; | ||
} | ||
public BinaryTreeNode getLeft() { | ||
return left; | ||
} | ||
public void setLeft(BinaryTreeNode left) { | ||
this.left = left; | ||
} | ||
public BinaryTreeNode getRight() { | ||
return right; | ||
} | ||
public void setRight(BinaryTreeNode right) { | ||
this.right = right; | ||
} | ||
|
||
public BinaryTreeNode insert(Object o){ | ||
return null; | ||
public TreeNode insert(TreeNode o){ | ||
if(node == null){ | ||
return o; | ||
} | ||
if(node.key > o.key){ | ||
return insert(o.leftChild); | ||
}else{ | ||
return insert(node.leftChild); | ||
} | ||
} | ||
|
||
} |