Search algorithms
- Created by: Tomiwaq
- Created on: 19-04-19 14:16
View mindmap
- Search algorithm
- Binary search
- 1) Find the middle item in the ordered list
- 2) If this the the item then stop search
- 3) If not compare the item to the middle item. This gives you two halves
- 4) You need to repeat steps 1) - 3) until you find the item
- 1b) (n+1) / 2 to find the middle item
- Better at larger lists
- Linear search
- Checks each item of the list in turn to see if it's the correct one
- 1) Look at the first item in the unordered list
- 2) If this is the item then stop
- 3) If not, look at next item
- 4) Repeat 2) - 3) until you have checked every item
- Much simpler but not as efficient. Best at small lists
- Once a list is ordered, binary searches are more efficient
- Binary search
Comments
No comments have yet been made