An open API service indexing awesome lists of open source software.

https://github.com/guanshiyin28/sequential-search-and-binary-search

Sequential Search and Binary Search (Python)
https://github.com/guanshiyin28/sequential-search-and-binary-search

binary-search binary-search-algorithm python python3 sequential-search sequential-search-algorithm

Last synced: 4 months ago
JSON representation

Sequential Search and Binary Search (Python)

Awesome Lists containing this project

README

        

# 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:

```python
# 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:**
```bash
git clone https://github.com/guanshiyin28/Sequential-Search-and-Binary-Search.git
```
2. **Navigate to the project directory:**
```bash
cd Sequential-Search-and-Binary-Search
```



## Steps to Run

To run the Python scripts, use the following commands:

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



## License

This project is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file for details.