剧组经典爆笑吵架,全是“蛋”·太他妈搞笑·大家乐乐··# Joke - 肚皮舞运动
y*m
1 楼
这个简单java的,有更简洁明了完善高效结构化的么,thx!
class BinaryTree {
private int data;
private int minNode = Integer.MAX_VALUE;
private BinaryTree leftpoiter;
private BinaryTree rightpoiter;
public BinaryTree() {
}
public BinaryTree(int data) {
this.data = data;
leftpoiter = null;
rightpoiter = null;
}
public void getMinNode(int key) {
getMinNode(this, key);
}
public void getMinNode(BinaryTree root, int key) {
if (root != null) {
if (root.data > key) {
minNode = (root.data < minNode) ? root.data : minNode;
getMinNode(root.leftpoiter, key);
} else
getMinNode(root.rightpoiter, key);
}
}
public boolean searchkey(int key) {
return searchkey(this, key);
}
public boolean searchkey(BinaryTree root, int key) {
if (root == null)
return false;
else if (root.data == key)
return true;
else if (key >= root.data)
return searchkey(root.rightpoiter, key);
return searchkey(root.leftpoiter, key);
}
public void createTree(int data[]) {
this.data = data[0];
for (int i = 1; i < data.length; i++) {
this.insertTree(this, data[i]);
}
}
public void insertTree(BinaryTree root, int data) {
if (data >= root.data) {
if (root.rightpoiter == null)
root.rightpoiter = new BinaryTree(data);
else
insertTree(root.rightpoiter, data);
} else {
if (root.leftpoiter == null)
root.leftpoiter = new BinaryTree(data);
else
insertTree(root.leftpoiter, data);
}
}
}
class BinaryTree {
private int data;
private int minNode = Integer.MAX_VALUE;
private BinaryTree leftpoiter;
private BinaryTree rightpoiter;
public BinaryTree() {
}
public BinaryTree(int data) {
this.data = data;
leftpoiter = null;
rightpoiter = null;
}
public void getMinNode(int key) {
getMinNode(this, key);
}
public void getMinNode(BinaryTree root, int key) {
if (root != null) {
if (root.data > key) {
minNode = (root.data < minNode) ? root.data : minNode;
getMinNode(root.leftpoiter, key);
} else
getMinNode(root.rightpoiter, key);
}
}
public boolean searchkey(int key) {
return searchkey(this, key);
}
public boolean searchkey(BinaryTree root, int key) {
if (root == null)
return false;
else if (root.data == key)
return true;
else if (key >= root.data)
return searchkey(root.rightpoiter, key);
return searchkey(root.leftpoiter, key);
}
public void createTree(int data[]) {
this.data = data[0];
for (int i = 1; i < data.length; i++) {
this.insertTree(this, data[i]);
}
}
public void insertTree(BinaryTree root, int data) {
if (data >= root.data) {
if (root.rightpoiter == null)
root.rightpoiter = new BinaryTree(data);
else
insertTree(root.rightpoiter, data);
} else {
if (root.leftpoiter == null)
root.leftpoiter = new BinaryTree(data);
else
insertTree(root.leftpoiter, data);
}
}
}