Used to retrieve information stored within some data structure. Below is an explanation of common searching algorithms along with their time and space complexities.
Common searching algorithms
Section titled “Common searching algorithms”Linear Search
Section titled “Linear Search”The simplest searching algorithm. It checks each element of the list sequentially until the desired element is found or the list ends.
Binary Search
Section titled “Binary Search”An efficient algorithm for finding an item from a sorted list of items. Works by repeatedly dividing the search interval in half.
Depth-first search and breadth-first search are explained in their respective sections.
Comparison
Section titled “Comparison”| Algorithm | Best Time | Worst Time | Average Time | Memory |
|---|---|---|---|---|
| Linear Search | ||||
| Binary Search | ||||
| Depth-First Search (DFS) | ||||
| Breadth-First Search (BFS) |