Download:

Linear Search Python Code (Code Needs To Be Copied Into Python)

Townlist (Text Document Needed For Python File to Work)

Note: Make sure that townlist and the python file is in the same folder for the program to work. Remove/add comments where needed in order test out variants

**Linear Search: (GCSE & A-Level)**

The Linear Search starts at the beginning item in the list and checks each item one by one until it finds the intended search term.

*Simplified Explanation:*

- Start at the first item in the list.
- If this item is the search term, then the search is complete.
- If the item is not the search term, then move to the next item in the list.
- Repeat Step 2 until the search term is found or when there are no more items in the list.

Linear Search in Python:

Advantages: |
Disadvantages: |

· Effective finding item in small data sets (Lists) | · Slowest type of search. Inefficient. |

· Can be used on any list (sorted or unsorted) | · Number of operations/loops can vary depending on the size of the data set (list) |

· Easy to program and easy to implement |

**Big O Notation of Linear Search (A-Level):**

Best Case |
Average Case: |
Worst Case |

· Constant | · Linear | · Linear |

· O(1) | · O(n) | · O(n) |

**Recursive Linear Search: (A-Level)**

870 total views, 1 views today