美文网首页
链表排序

链表排序

作者: 啊磊11 | 来源:发表于2021-03-23 22:47 被阅读0次

    //链表 排序

    public static LinkedLISTtask44(LinkedLIST head){

    LinkedLIST dummy =new LinkedLIST(-1,null);

        dummy.next = head;

        LinkedLIST pre = dummy;

        LinkedLIST curr = head;

        LinkedLIST wait =null;

        while (curr !=null && curr.next !=null){

    wait = curr.next;

            if(wait.value

    while (pre.next !=null && wait.value >pre.next.value){

    pre = pre.next;

                }

    LinkedLIST temp1 = wait.next;

                LinkedLIST temp2 = pre.next;

                pre.next = wait;

                wait.next = temp2;

                curr.next = temp1;

                pre = dummy;

            }else{

    curr = curr.next;

            }

    }

    return dummy.next;

    }

    相关文章

      网友评论

          本文标题:链表排序

          本文链接:https://www.haomeiwen.com/subject/giiqhltx.html