我目前在我的mac上安装了python 2.7.6和3.4。我想将python2升级到python 2.7.8,因为我认为它更安全。这样做的正确方法是什么?我只是从网站上下载安装程序并运行它吗?如果是这样,我的系统会自动使用2.7.8而不是之前安装的2.7.6吗?
请注意,python版本2.7.6已预先安装。如果这个问题看起来多余,我会道歉。我以前盲目地开发而不考虑版本和软件包,弄乱了我的项目。所以现在我试着小心。
答案 0 :(得分:0)
public Node Insert(int value)
{
Node newNode = new Node();
newNode.data = value;
newNode.left = null;
newNode.right = null;
if(root == null){
root = newNode;
return root;
}
else{
while(root != null){
if(root.data < value){
if(root.right != null){
root = root.right;
// root should point to the head of the tree.
/* Here you are changing the variable root to point to some other memory location and the reference to the head of the tree is lost. You should store the reference to the head of the tree in a temporary variable to return later */
}
else{
root.right = newNode;
break;
}
}
else{
if(root.left != null){
root = root.left;
//root should point to the head of the tree.
/* Here you are changing the variable root to point to some other memory location and the reference to the head of the tree is lost. You should store the reference to the head of the tree in a temporary variable to return later */
}
else{
root.left = newNode;
break;
}
}
}
// return temporary variable which points to the head of the tree here
return root;
}
}
public void inOrder(){
inOrder(this.root);
}
private void inOrder(Node root){
if(root != null){
inOrder(root.left);
System.out.println(root.data);
inOrder(root.right);
}
}
是一个简单的Python版本管理。您可以在pyenv上找到更多信息。