Monday, 31 March 2014

Sorting and Efficiency

Well this one's a bit late but here it is... sorting and how efficient they are. In all programming, how efficient the sort works is how compared to how long it takes to sort a set amount of data as the amount of data increases. This is important of course because in real life situations, there could be big companies that need to sort payrolls and those could contain millions have entries that need to be sorted constantly. If you had an inefficient sorting for them, it would take ages for it to process everything. The most basic sorts that we looked at were all either in the worst case scenario, n^2 or nlogn run times. These sorts were the bubble, insertion, selection, merge and quick sorts. Basically what this means is when you run one of the sorts, the time it takes to sort the data will grow proportional to how much n has grown squared. These begin to take a fair amount of time as n gets really large so using merge sort for extremely large lists n is much better since it has a run time of nlogn, which is much less than n^2 for large n. Basically the key idea is that you want to have more efficient sorting algorithms because the bigger the list gets, the less time it will take. Big-O is looking at the worst case scenario of each sort and determining their run time and how it grows for extremely large lists n.

No comments:

Post a Comment