CS 022A Lecture Notes - Lecture 13: Linear Search, Binary Search Algorithm

16 views2 pages

Document Summary

Searching through the list one by one until target value found. Linear search starts at the beginning examining one item after another. Searching is a very common programming problem -- the process of looking for a particular value in a collection. Python provides a number of built in search related methods/operations. Two possible outcomes -- the main loop with two ending conditions. Linear search is successful --key is found. Linear search failed -- key does not exist in data. Algorithm stop either when we have found the item or when we have looked at all the items and not found a match. A linear search is the most basic algorithm for finding a specific value within a list or an array. Basically, the algorithm searches sequentially through the list checking every item until you find the specified value. In the worst case linear search will have to check every single item in the list.

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