Note: This is part 1 of a 2 part question.
I’m wanting to more about sorting algorithms and what better way to do than then to code! So I figure I need some data to work with.
My approach to creating some “standard” data will be as follows: create a set number of items, not sure how large to make it but I want to have fun and make my computer groan a little bit 😀
Once I have that list, I’ll push it into a text file and just read off that to run my algorithms against. I should have a total of 4 text files filled with the same data but just sorted differently to run my algorithms against (see below).
Correct me if I’m wrong but I believe I need 4 different types of scenarios to profile my algorithms.
- Randomly sorted data (for this I’m going to use the knuth shuffle)
- Reversed data (easy enough)
- Nearly sorted (not sure how to implement this)
- Few unique (once again not sure how to approach this)
This question is for generating a nearly sorted list.
Which approach is best to generate a nearly sorted list on predefined data?
Answering my own question here. All this does is taking a sorted list and shuffling up small sections of it.