LEARNING JOURNAL

I created this learning journal to practice writting and to help me learn by writting everything down. Source code here

1/26/2024

Insertion Sort List #2 attempt

This is my second attempt solving the problem Insertion Sort List

Here is something that I learned during this attempt:

  1. Actually, there are two lists: the old list that is given to us and the new list that we create by putting elements from the old list, one by one, in the sorted order and then returning it.
  2. I used the pointer pos to keep track of the current position in the old list and dummy node to get a hold of the new list.
  3. After each iteration, one node will be cut off from the old list and moved to the new list. The pos pointer always points to the beginning of the already cut off old list. Thus, we need to move it to the next node BEFORE we cut off the current element from the old list.