This repository contains C++ and Python implementations of various searching algorithms. Each algorithm is well-documented, optimized for general use, and includes time complexity analysis. Ideal for learning, interviews, and competitive programming! π
πΉ Linear Search β Iterates through the array to find an element (O(n)).
πΉ Binary Search β Efficient search for sorted arrays using divide & conquer (O(log n)).
πΉ Ternary Search β Similar to binary search but splits into three parts (O(log n)).
πΉ Interpolation Search β Works well on uniformly distributed data (O(log log n) avg).
πΉ Jump Search β Faster than linear search; jumps ahead by fixed steps (O(βn)).
πΉ Exponential Search β Starts with small steps, then switches to binary search (O(log n)).
πΉ Hash Table Search β Uses hash functions for constant-time lookups (O(1) avg).
π Searching-Algorithms
βββ π linear_search.cpp
βββ π binary_search.cpp
βββ π ternary_search.cpp
βββ π interpolation_search.cpp
βββ π jump_search.cpp
βββ π exponential_search.cpp
βββ π hash_search.cpp
βββ π linear_search.py
βββ π binary_search.py
βββ π ternary_search.py
βββ π interpolation_search.py
βββ π jump_search.py
βββ π exponential_search.py
βββ π hash_search.py
βββ π README.md
| Algorithm | Best Case | Average Case | Worst Case |
|---|---|---|---|
| Linear Search | O(1) | O(n) | O(n) |
| Binary Search | O(1) | O(log n) | O(log n) |
| Ternary Search | O(1) | O(log n) | O(log n) |
| Interpolation Search | O(1) | O(log log n) | O(n) |
| Jump Search | O(1) | O(βn) | O(βn) |
| Exponential Search | O(1) | O(log n) | O(log n) |
| Hash Table Search | O(1) | O(1) | O(n) |
1οΈβ£ Clone this repository
git clone https://github.com/CyberMatic-AmAn/Searching.git2οΈβ£ Compile and run any searching program
For C++:
g++ binary_search.cpp -o binary_search
./binary_searchFor Python:
python binary_search.pyFeel free to fork this repo, improve the code, and submit pull requests! π