Quote (Aimed_Shot @ Oct 1 2014 11:53pm)
my guess is they are implementing various sorting algorithms and then looking at the run time. and the prof wanted to show that different sorting algorithms can have drastically different run times. Then wanted them to try it on large size array so they can actually see the differences. i.e. if you do all the different sorts with n=50 you won't really be able to see any difference in time
You can do that simply by plugging in the array size to N^2 of O(N^2). You don't tell a bunch of freshmen that your implementation must work for 10^7 sized array. Because before you talk about run-time analysis of comparison based sorting algorithms, all they will think is "shit I ran the program and it froze...I must have messed up the implementation." So you end up having issues like what OP is having. His algorithm is a fine insertion sort, but he is too hung up on making it work for 10^7 because he hasn't been taught anything about the run-time of O(n^2) algorithms. This was a shitty assignment.
The correct way to do this would be to have him implement insertion sort and then give him sample test data. Then have him implement bubble sort, selection sort. Then have him implement mergesort or quicksort. Then after you have gone through all of those tell him to run each with new sample data. This time the data has the 10^7 array. Now he gets to see each sorting algorithm handle that data. After he does that he is to answer one question: Explain why quicksort and mergesort were able to sort this data but insertion and selection sort took ages. By then, in lecture, the professor would have already gone over each algorithm and explained its run-time and what it means. Now the student is equipped to handle this concept.
Do you see the difference?