Original Post
I have this project for school where I need to write a sorting algorithm that will work for one billion 5 character strings [a-u, A-U]. I'm not looking for answers, more just ideas some of you might have. It's supposed to be done in C++ on a single computer with a single hard drive. And the algorithm needs to be black boxed. It should work with 100, 1000, 10000, etcetera 5 character strings. It needs to figure it out at runtime on it's own. After it's sorted I need to search for 2 strings hidden in the billion strings. What i'm planning now is a merge sort of some kind. Before I start reading from the file, i'll create a bunch of files on the hard drive which will be responsible for holding strings starting with a certain character. eg. filenames[a.dat, b.dat, c.dat, ... G.dat, H.dat,...]. As I pull the data out of the main file, i'll throw it into the appropriate temp file...the string abHgu would go to the a.dat file. Once I reach the end of the main file, i'll go and sort each individual file and then merge them back into one file. When i'm reading the initial data, i'll probably open a couple hundred streams (you can open 509 simultaneously in vs2005...3 are reserved for cin, cout, cerr) and have each one read like every nth string. Anyway, any hints or ideas people might like to share, or point out anything that might push me in a better direction or point something out I'm getting wrong, would be very much appreciated.