Skip to content

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! πŸš€

Notifications You must be signed in to change notification settings

CyberMatic-AmAn/Searching

Repository files navigation

Searching Algorithms in C++ & Python πŸ”βš‘

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! πŸš€

πŸ“Œ Included Searching Algorithms

1️⃣ Linear Searching

πŸ”Ή Linear Search – Iterates through the array to find an element (O(n)).

2️⃣ Binary Searching

πŸ”Ή 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)).

3️⃣ Interpolation Searching

πŸ”Ή Interpolation Search – Works well on uniformly distributed data (O(log log n) avg).

4️⃣ Jump Searching

πŸ”Ή 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)).

5️⃣ Hashing-Based Search

πŸ”Ή Hash Table Search – Uses hash functions for constant-time lookups (O(1) avg).

πŸ“‚ Folder Structure

πŸ“‚ 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  

⏳ Time Complexity Comparison

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)

πŸ’‘ How to Use?

1️⃣ Clone this repository

git clone https://github.com/CyberMatic-AmAn/Searching.git

2️⃣ Compile and run any searching program
For C++:

g++ binary_search.cpp -o binary_search
./binary_search

For Python:

python binary_search.py

πŸ“Œ Contributions

Feel free to fork this repo, improve the code, and submit pull requests! πŸš€

About

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! πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published