0
ソートしたままリンクリストに100を追加するにはどうすればよいですか?私は、単一リンクリストの先頭にアイテムを追加し、リストの最初のノードを指し示さなければならないことを知っていますが、この問題を解決する方法を見つけるのには非常に問題があります。特定のデータを持つリストにノードを挿入し、そのリストをJavaでソートする方法
IntegerNode n3 = new IntegerNode(9, null);
IntegerNode n2 = new IntegerNode(5, n3);
IntegerNode head = new IntegerNode(1, n2);
IntegerNode curr;
IntegerNode prev;
//print all the items in the linked-list
for(curr = head; curr!=null; curr = curr.getNext()) {
System.out.println(curr.getItem());
}
int data = 100;
//insert an node to the list with the given data, and maintain the list to be sorted
}
}