ENGR 101 Lecture Notes - Lecture 21: Ex-Gay Movement, Insertion Sort, Bubble Sort

141 views2 pages
17 Apr 2015
School
Department
Course

Document Summary

Engr 101: introduction to computers and algorithms - lecture 21: common algorithms. 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 a value in a sorted vector, a. Compare the value against the middle element of a and there are three possibilities. Value is equal, greater, or less than the element. If value is equal, the index 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