Okay, looking at your Bubble Sort, I noticed a few things:
- First off, it crashes when the list is empty, i.e. when passed NULL as the head of the list. An empty list occurs very often in practice.
- safeFirst is unused.
- What is the result of executing these three statements, and can you see how they would be executed in your function?
Code:plat1 = first;- plat3 = first;
- (*plat3).next = plat1;
- You can do away with 'n' by testing if 'plat1' equals 'first' instead.
- Did you know that Insertion Sort for a list is easier to implement than Bubble Sort!
I'll let you think about that much for now.