CSCI 2824 Lecture Notes - Lecture 17: Insertion Sort

33 views4 pages

Document Summary

If max < ai, then max = ai. Procedure linearsearch (x, a1, a2, , an) i = 1. While (i <= n and x ai) i = i+1. If i <= n then location = i. Procedure binarysearch(x, a1, a2, , an) i = 1 # i is left endpoint of search interval j = n # j is right endpoint of search interval. While i < j m = (i+j)/2 # m is index of largest in left list. If x > am then location = i, else location = -1. Return location procedure bubblesort (a1, a2, , an) for i = q to n-1 for j = 1 to n-1. {a list is an increasing order} procedure change (c1, c2, , cr) for i = 1 to r di = 0 # di counts coins of denom. ci.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions