Another crucial skill to master in the field of computer science is how to search for an item in a collection of data quickly. Here are the most common searching algorithms, their corresponding data structures, and time complexities.

Here are the main searching algorithms:

Algorithm | Data Structure | Time Complexity - Average | Time Complexity - Worst | Space Complexity - Worst |
---|---|---|---|---|

Depth First Search | Graph of |V| vertices and |E| edges | - | O(|E|+|V|) | O(|V|) |

Breadth First Search | Graph of |V| vertices and |E| edges | - | O(|E|+|V|) | O(|V|) |

Binary Search | Sorted array of n elements | O(log(n)) | O(log(n)) | O(1) |

Brute Force | Array | O(n) | O(n) | O(1) |

Bellman-Ford | Graph of |V| vertices and |E| edges | O(|V||E|) | O(|V||E|) | O(|V|) |