这是用于按升序对双向链接列表进行排序的代码,但不适用于列表中的重复项

问题描述 投票:-1回答:1

查找错误

Node node = head;//create a new node
while(node.next != null){
    if(node.data>node.next.data){  //comparing next node and node
        int x;
        x = node.data;
        node.data = node.next.data;  //changing the value of next node and current node
        node.next.data = x;
    }
    node = node.next; //changing to next node
}  
java data-structures
1个回答
0
投票

如果您对该概念有疑问,可以参考一些在线教程。GFG

这是先前提出的问题。Asked question

您应该在IDE中启用debugging。启用调试后,请仔细查看您的代码流,并检查代码错误。

© www.soinside.com 2019 - 2024. All rights reserved.