Algorithm for generating a nearly sorted list on predefined data
This is part 1 of a 2 part question. Part 2 here.
I'm wanting to know more about sorting algorithms so I need to create 4 text files with the same data sorted differently to run my algorithms against:
- Randomly sorted data (I'm going to use Knuth shuffle)
- Reversed data
- Nearly sorted (not sure how to implement this)
- Few unique (not sure how to approach this)
Which approach is best to generate a nearly sorted list on predefined data?