CP104 Lecture Notes - Lecture 2: Linear Search, Binary Search Algorithm, Auxiliary Memory

122 views3 pages
Verified Note
10 Sep 2018
School
Course
Professor

Document Summary

Starting at the beginning of the list, look at each element one by one in the list and compare if to the number you are trying to find. Stop when you have found the matching number or have reached the end of the list. This is called a linear search: assuming the elements of the list are in order , split the list in two. If the number you are looking for matches the number in the middle, stop/ if the middle is greater than the number, repeat in the left half of the list. If the middle is less than the number, repeat in the right half of the list/ stop when you have found the matching number or when you can no longer split the list in half. This is called a binary search. (we will see more of both of these algorithms later!)

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