bubble sort implementation on linked lists

后端 未结 6 1426
小蘑菇
小蘑菇 2020-12-11 14:06

I have to implement a BubbleSort algorithm on a Linked List instead of an array. I\'m new to java so I don\'t really know how to put it in code. But I gave it a try and here

6条回答
  •  忘掉有多难
    2020-12-11 14:22

    1) You need to implement Comparable

    2) You also need to use the swap method in bubblesort. Currently you are not using this and it will only compare the two objects without swapping them in the actual list.

    Use the tutorial for the Comparable

提交回复
热议问题