ENGR 101 Lecture 21: 21LectureNotes

25 views5 pages
24 Jan 2017
School
Department
Course

Document Summary

Often sequences of data are more useful if the elements are in order. Rearranges a data sequence so that the elements are in order. Is a very common and useful category of algorithms. Go through the list, swapping adjacent places when out of order. Ensures that the highest gets to the end. Then go through the list again, swapping as we go . Ensures that the second highest is second to the end. Create new sorted list by going through input list one-by-one. For each input item, go through new list in order, stop and insert in place that would maintain order. Suppose we are looking for value in a sorted vector, a. Compare the value against the middle element of a and there are three possibilities: Value is equal to the middle element. If it"s case 1, we"re done and the index of the value was found.

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