COMP 1005 Lecture Notes - Lecture 12: Sorting Algorithm, Mathematical Notation, Time Signature

19 views6 pages

Document Summary

Know how to calculate the complexity of algorithms. There are various sorting algorithms such as bubble sort, quick sort, insertion sort, selection sort, and merge sort. In a comparison-based sorting algorithm, we compare elements in the list and make decisions based on these comparisons. Python automatically knows how to compare numbers with other numbers and strings with other strings. Insertion sort takes elements one by one from an unsorted array and inserts them into a new sorted array. Selection sort divides an array into two arrays: sorted and unsorted. At the start of sorting, the sorted array is empty. The unsorted array is the initial given array. It is useful when the array size is small. The two methods maintain an invariant throughout its execution. An invariant is something that remains true as the algorithm executes. The selection sort builds up its sorted partition by selecting the minimum value remaining in the unsorted partition.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers