Skip to main content
1 of 2

They seem right to me. A few minor comments:

  1. You don't need to construct your lists by adding .add(pos, value). You can build them from an array as:

    int[] array = {6,12,9,-14}; List list = new ArrayList<>(Arrays.asList(array);

which is more concise and readable.

  1. In your bubblesort, you do:

    Integer temp1= unsortedList.get(i + 1); Integer temp2= unsortedList.get(i);

accessing unsortedList twice. If you assign outside the IF, you can recycle it and make it more readable. Also, consider using better names than temp1 and temp2: not much difference here, but it's a good habit to get into. Same for insertion.