Friday 22 November 2013

Sorting algorithms efficiencies

So I just had my tutorial today. It was pretty simple although recording the information in the spreadsheet took a lot of time but there are important points that we should benefit from :

  • The List sort is the best in all cases (random, sorted and sorted reversed ) then comes the quick sort with both it's algorithms.
  • When our data is sorted , bubble sort and insertion sort benefited the most from that.
  • When our data is sorted reversed bubble sort was the most affected (i.e took more time ) since a swap will occur every time since numbers are in descending order and swapping takes time.

2 comments:

  1. Yup, it was a pain recording all that information. Also, it's worth noting that the version of quicksort that was implemented chose the first index as the pivot. This means it would do very poorly on a perfectly sorted or perfectly unsorted list since the partition doesn't really do anything (quicksort works most efficiently when it chooses the median value as the pivot). It would be much better if we used a version of quicksort which chooses a random index and uses the corresponding value as the pivot.

    ReplyDelete
  2. Yes thats a good point to notice as well.

    ReplyDelete