notes13d

Notes13d

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [4,9,3,7,6] Input Output [4,9,3,7,6] [4,3,7,6] [9] [4,3,6] [7,9] [4,3] [6,7,9] [3] [4,6,7,9] [3,6,7,9] Python Code for selection sort: n - 1 Time complexity: O(n²) Insertion Sort 1. For all items in the list, insert the ith item into the i- 1 sorted ones Example: [4,9,3,7,6] i List 0 [4,9,3,7,6] – 4 is the first element, it is not less than anything so far 1 [4,9,3,7,6] – 9 is compared to [4]. It is not less than 4 so it is the second item 2...
View Full Document

This note was uploaded on 02/04/2014 for the course CS 234 taught by Professor Baranoski during the Spring '09 term at Waterloo.

Ask a homework question - tutors are online