Cover image for Searching Algorithms Every Programmer Should Know

Searching Algorithms Every Programmer Should Know

Suraj Vishwakarma

18 Jul, 2025


Introduction

Welcome to the first part of the series: "Algorithm Every Programmer Should Know." In this series, we explore fundamental algorithms including Searching, Sorting, Graphs, Arrays, and more.

Today, we begin with the Searching Algorithms. These algorithms help you efficiently find data within a collection. We cover four core searching techniques that every programmer must know.


Linear Search

Linear search (or sequential search) checks each element in a list until the target is found or the entire list has been searched.

Linear Search

How it works:

Performance:

When to Use Linear Search:


Binary Search

Binary search finds the position of a target value in a sorted array by repeatedly dividing the search interval in half.

Binary Search

How it works:

Performance:

When to Use Binary Search:


Depth First Search (DFS)

DFS traverses or searches through a graph/tree structure by exploring as deep as possible along each branch before backtracking.

Depth First Search(DFS)

How it works:

Performance:

When to Use DFS:


Breadth First Search (BFS)

BFS traverses or searches graph/tree structures by exploring all neighbors at the current depth before moving on to the next level.

Breadth First Search(BFS)

How it works:

Performance:

When to Use BFS:


Conclusion

Thank you for reading! Stay tuned for the next part in the "Algorithm Every Programmer Should Know" series. If you found this helpful, feel free to share it with others.


Build by Suraj Vishwakarma.