Skip to content

This repository provides Python implementations of two fundamental search algorithms: Sequential Search and Binary Search. It includes detailed and easy-to-understand code for both algorithms, showcasing their functionality, use cases, and performance differences.

License

Notifications You must be signed in to change notification settings

n4vrl0s3/Sequential-Search-and-Binary-Search

Repository files navigation

Sequential Search and Binary Search

This repository aims to provide a comprehensive starting point for understanding and implementing two fundamental search algorithms: Sequential Search and Binary Search. These search algorithms are implemented in Python and serve as a great introduction to search techniques for beginners and intermediate programmers.



Purpose of This Repository

The purpose of this repository is to help users understand and implement two basic search algorithms in Python. It includes detailed explanations, code examples, and usage instructions for both Sequential Search and Binary Search.



Demonstration

Here is a quick demo of how the search algorithms work:

# Sequential Search Example
def sequential_search(arr, target):
    for i in range(len(arr)):
        if arr[i] == target:
            return i
    return -1

# Binary Search Example
def binary_search(arr, target):
    low = 0
    high = len(arr) - 1
    while low <= high:
        mid = (low + high) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] < target:
            low = mid + 1
        else:
            high = mid - 1
    return -1


Features

  • Implementation of Sequential Search in Python
  • Implementation of Binary Search in Python
  • Example usage of both search algorithms
  • Detailed comments and explanations


Technologies Used

  • Python


Project Setup

To set up the project locally, follow these steps:

  1. Clone the repository:
    git clone https://github.com/n4vrl0s3/Sequential-Search-and-Binary-Search.git
  2. Navigate to the project directory:
    cd Sequential-Search-and-Binary-Search


Steps to Run

To run the Python scripts, use the following commands:

  1. Run the Sequential Search script:
    python program_v2.py
  2. Run the Binary Search script:
    python program.py


License

This project is licensed under the MIT License. See the LICENSE file for details.



About

This repository provides Python implementations of two fundamental search algorithms: Sequential Search and Binary Search. It includes detailed and easy-to-understand code for both algorithms, showcasing their functionality, use cases, and performance differences.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages