Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order. Efficient sorting.

Similar presentations


Presentation on theme: "Introduction A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order. Efficient sorting."— Presentation transcript:

1 Introduction A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order. Efficient sorting is important for optimizing the use of other algorithms which require input data to be in sorted lists. Sorting algorithm is also often useful for producing human-readable output. Our goal is to find out the advantage of each sorting algorithm. Materials and methods We choose bubble sort, insertion sort, quick sort and merge sort for our research. Bubble Sort · ● Algorithm compares the two elements adjacent to each other, and swaps place when the front number is bigger. ● Repeat step one until the last element is the biggest number. ● Repeat step one and step two, algorithm compares elements until last round. ● Repeat all steps until no elements need to be compared. Here is the example for bubble sort algorithm. Merge Sort ● Divide the unsorted list into n sub-lists, each containing 1 element (a list of 1 element is considered sorted). ● Repeatedly merge sub-lists to produce new sorted sub-lists until there is only 1 sub-list remaining. This will be the sorted list. Here is the example for merge sort algorithm. Acknowledgments We thank Stephanie Wey for laboratory assistance, Kobe Bryant for equipment, Chris Paul for technological guidance, and Michael Jordan for providing useful advice. My mom and the Harvard University funded this project. Insertion Sort ●The element of an array is compared with the elements that appears before it. ● If the front element is bigger than itself, it will be inserted in the position of the front element. ● Repeat all steps until all elements have been sorted. Here is the example for insertion sort algorithm. Quick Sor t ● Pick an element to be a pivot from the array. ● Elements with values less than the pivot come before the pivot. Elements with values greater than the pivot come after the pivot. ● Repeat all the steps to the sub-array. Conclusions ● Generally, Quick-sort is the fastest algorithm compare to Bubble sort, Merge sort and Insertion sort. ● In our study, every sort algorithm has advantage and disadvantage. We need to consider our requirement and data type for selecting the proper sort algorithm. Kevin Chang Department of Computer Science, Harvard University Literature cited < http://freefeast.info/general-it-articles/insertion-sort- pseudo-code-of-insertion-sort-insertion-sort-in-data- structure/ < http://freefeast.info/general-it-articles/insertion-sort- pseudo-code-of-insertion-sort-insertion-sort-in-data- structure/ > < http://en.wikipedia.org/wiki/Insertion_sort < http://en.wikipedia.org/wiki/Insertion_sort > < http://program- lover.blogspot.tw/2008/10/mergesort.html > http://program- lover.blogspot.tw/2008/10/mergesort.html < http://emn178.pixnet.net/blog/post/87965707- 合併 排序法 (merge-sort) > http://emn178.pixnet.net/blog/post/87965707- 合併 排序法 (merge-sort) < http://en.wikipedia.org/wiki/Merge_sort > http://en.wikipedia.org/wiki/Merge_sort < http://www.programiz.com/article/insertion-sort- algorithm-programming > http://www.programiz.com/article/insertion-sort- algorithm-programming < http://en.wikipedia.org/wiki/Quicksort > http://en.wikipedia.org/wiki/Quicksort < http://www.cs.swarthmore.edu/~soni/cs35/f13/Labs/i mages/06/quickSort.png < http://www.cs.swarthmore.edu/~soni/cs35/f13/Labs/i mages/06/quickSort.png > < http://www.chwa.com.tw/TResource/HS/book2/ch7/7 -5.htm < http://www.chwa.com.tw/TResource/HS/book2/ch7/7 -5.htm > For further information Please contact laker@fas.harvard.edu. More information on this and related projects can be obtained at www.laker.google.com. Results Bubble Sort ●Generally, bubble sort algorithm needs to compare at least 1+2+3+……+n-1=n(n-1)/2 times. Time complexity is O(n2). ● Bubble sort algorithm do not occupy too much memory because it needs only one temporary variable. ● Bubble sort algorithm works better when using on small data. Merge Sort ● Merge sort is often the best choice for sorting a linked list. ● Time complexity is O(nlogn). ● Merge sort parallelizes well due to use of the divide-and-conquer method. ● Most implementations produce a stable sort, meaning that the implementation preserves the input order of equal elements in the sorted output. Insertion Sort ● Time complexity is O(n^2). ● Insertion sort algorithm does not change the relative order of elements with equal keys. ● Insertion sort algorithm only requires a constant amount O(1) of additional memory space. Quick Sort ● Quick-sort is often faster in practice than other O(n log n) algorithms. ● Time complexity is O(nlogn). ● Quick-sort is often faster in practice than other O(n log n) algorithms. ● Quick-sort is a comparison sort and, in efficient implementations, is not a stable sort. ● The depth of quick-sort's divide-and-conquer tree directly impacts the algorithm's scalability, and this depth is highly dependent on the algorithm's choice of pivot. Sort Research


Download ppt "Introduction A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order. Efficient sorting."

Similar presentations


Ads by Google