Solution at each step choose the coin with the largest

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: 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 fiber links among nodes using the least amount of fiber. —...
View Full Document

Ask a homework question - tutors are online