小编Pat*_*rth的帖子

克隆带有随机指针的二叉树

谁能解释用从左到右的随机指针克隆二叉树的方法?每个节点都有以下结构。

struct node {  
    int key; 
    struct node *left,*right,*random;
} 
Run Code Online (Sandbox Code Playgroud)

这是一个非常受欢迎的面试问题,我能够根据散列(类似于链表的克隆)找出解决方案。我试图理解链接(方法 2)中给出的解决方案,但也无法通过阅读代码弄清楚它想传达什么。我不期望基于散列的解决方案,因为它直观且非常直接。请解释基于修改二叉树并克隆它的解决方案。

c algorithm recursion binary-tree data-structures

5
推荐指数
1
解决办法
2577
查看次数

类Integer中的valueof值

我们知道Integer类中的valueof值是静态的.但是当我们通过Integer类的对象调用时,它没有给出任何错误.例如:以下代码运行完美...

public class Test {
    public static void main(String[] args)
    {

        Integer i=new Integer(5);
        System.out.println(i.valueOf(i));
    }
}
Run Code Online (Sandbox Code Playgroud)

java

1
推荐指数
1
解决办法
82
查看次数

标签 统计

algorithm ×1

binary-tree ×1

c ×1

data-structures ×1

java ×1

recursion ×1