Searching Algorithms

The following table shows the complexities for searching algorithms:

Algorithm Data Structure Worst Cases
Sequential search Array O(n)
Binary search Sorted array O(log(n))
Interpolation search Sorted array O(n)
Depth-first search (DFS) Graph of |V| vertices and |E| edges O(|V| + |E|)
Breadth-first search (BFS) Graph of |V| vertices and |E| edges O(|V| + |E|)

Get Learning JavaScript Data Structures and Algorithms - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.