CSCA48H3 Lecture Notes - Lecture 19: Hash Table, Insertion Sort, Selection Sort

32 views4 pages

Document Summary

Csca48 - lecture 19 - sorting (part 1) The process of re-ordering items such that every item is placed in its right place. A requirement for other algorithms (ex: in place binary search) Running time is dependent on the number of inputs. For small collection of data, it is possible that a less efficient algorithm works better due to less overload. Count the number of comparisons and the exchange required. In each pass, replace the next largest item in its right place. We need to have each of the n items compare with the rest of items (n - 1 times) At the start of the first pass, we will have n items to sort and n - 1 comparisons to make. # every item in the list should be placed in its right place. # there are n numbers in the list, so we need to iterate comparing. # the items n times for i in range(len(a_list)):

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

Related Documents