This preview shows page 1. Sign up to view the full content.
Unformatted text preview: position. procedure insertion sort (a1,…,an: real numbers with n ≥ 2) for j := 2 to n i := 1 3 2 4 1 5 while aj > ai a. 2 3 4 1 5 i := i + 1 temp := aj b. 2 3 4 1 5 for k := 0 to j − i − 1 c. 1 2 3 4 5 aj k := aj k 1 d. 1 2 3 4 5 ai := temp http://www.cs.armstrong.edu/liang/animation/InsertionSortAnimation.html Greedy Algorithms ༉ Optimization problems minimize or maximize some parameter over all possible inputs. For instance, we can refer to: ༉ Finding a route between two cities with the smallest total mileage. ༉ Finding the ﬁber links among nodes using the least amount of ﬁber. ...
View Full
Document
 Spring '14
 M.Nojoumian
 Algorithms, Sort

Click to edit the document details