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)
- Host: GitHub
- URL: https://github.com/guanshiyin28/sequential-search-and-binary-search
- Owner: guanshiyin28
- License: apache-2.0
- Created: 2024-12-31T09:39:51.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2025-01-25T19:10:15.000Z (5 months ago)
- Last Synced: 2025-01-25T19:23:16.372Z (5 months ago)
- Topics: binary-search, binary-search-algorithm, python, python3, sequential-search, sequential-search-algorithm
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
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.