2.3.4 searching algorithms

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

8 Terms

1
New cards

binary search

  • can only be applied on sorted data

  • efficient for large data sets as it discards half the data after each iteration

  • works by finding the middle element in a list of data, comparing it to the element being searched for, before deciding which side of the data the desired element is to be found in

    • if list cant be divided, round to nearest whole number

  • the unwanted half of the data is then discarded

  • the process is repeated until the desired element is found or until it is known that the desired element doesn’t exist in the data

2
New cards

linear search

  • doesn’t require data to be in order

  • efficient for smaller data sets, inefficient for large data sets

  • starts at the first item in the list and checks each item one by one

  • when the item being searched for is found the search ends

3
New cards

ADV breadth first

  • more efficient when the data being search for is closer to the root

  • in general has abetter time complexity than depth first

4
New cards

ADV depth first

  • more efficient when the data being searched for is further down the tree

  • memory requirement is linear

  • can be written recursively to aid understanding

  • DIS

  • in large trees it may never return a value

5
New cards

binary search pseudocode

knowt flashcard image
6
New cards

binary search python

knowt flashcard image
7
New cards

linear search pseudocode

knowt flashcard image
8
New cards

linear search python

knowt flashcard image