Algs4-1.3.25编写一个方法insertAfter()

1.3.25编写一个方法insertAfter(),接受两个链表结点作为通用数,将第二个结点插入链表并使之成为第一个结点的后续结点(如果两个参数为空则什么也不做)。
答:
public  insertAfter(Node x,Node y)
{
    if(!(x==null || y==null))
        y.next=x.next;
        x.next=y;
 }

posted @ 2018-10-25 14:21  修电脑的龙生  阅读(185)  评论(0编辑  收藏  举报