Almost all Searching and Sorting Algorithms for Python 3.x
Project description
searchsort
A Python Package that contains almost all the Searching and Sorting Algorithms
It is also available in GitHub
Installation
If there are 2 or more versions of Python installed in your system (which mostly occurs in UNIX/Linux systems) then please run any one of the commands in the BASH Shell :-
$ pip3 install searchsort
$ python3 -m pip install searchsort
If there is only Python 3.x installed in your system like in Windows systems then please run any one of commands in the Command Prompt :-
pip install searchsort
python -m pip install searchsort
Quick Guide
Please Read till the End
- Import the Package using
import searchsort as ss
. ss.AvailableSearchingAlgorithms()
will show you the available Searching algorithms.ss.AvailableSortingAlgorithms()
will show you the available Sorting algorithms.- All the Functions have their Asymptotic Analysis in their docstrings. If you wish; you may take a note of it.
A Searching Implementation
from random import shuffle
import searchsort as ss
L1 = [i for i in range(1, 51)]
element = 20
# Shuffling the List
shuffle(L1)
index = ss.LinearSearch(L1, element)
if index:
print(f"{element} found at :", index)
else:
print(f"{element} not found")
Note :-
- Some of the Algorithms require a sorted array. It is mentioned in the docstring of the functions so please read them carefully.
- All the Algorithms return the index of the First Occurrence of the element.
- If Element is Not Present, False is Returned.
A Sorting Implementation
from random import shuffle
import searchsort as ss
L1 = [i for i in range(1, 51)]
# Shuffling the List
shuffle(L1)
print("List Before Sorting :", L1)
Result = ss.BubbleSort(L1)
print("List After Sorting :", Result)
Note :-
- Some of the Algorithms perform an in-place sorting, which means the structure of the Original List will be changed.
- All the Algorithms return the sorted array, so assigning statements are preferred.
'IsSorted' Function Implementation
Besides Searching an Element in an Array and Sorting Arrays, the Package also contains an 'IsSorted' Function that Returns True if an Array is SORTED in either direction; False If NOT.
from random import shuffle
from searchsort import IsSorted
L1 = [i for i in range(1, 51)]
print("Is the List Sorted Now? ", IsSorted(L1))
# Shuffling the List
shuffle(L1)
print("Is the List Sorted Now? ", IsSorted(L1))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file searchsort-0.1.6.tar.gz
.
File metadata
- Download URL: searchsort-0.1.6.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23d54061c5d390a0c7b3819c8385e3004c7d35ddbd8eea66a9311497cd3e9521 |
|
MD5 | db683ba845bf4bc1247b06853b5655c3 |
|
BLAKE2b-256 | 00d08b7c8f937c903ec37d579296252eda0f45aa7a523027b084c2bac1186492 |
File details
Details for the file searchsort-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: searchsort-0.1.6-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aafe97a8dd821371655704b4be8c7f3323fa6db63ed9dff393d29c8dcc081160 |
|
MD5 | 650d7c59984ce35b15b8dec460c85787 |
|
BLAKE2b-256 | cc5034866b28b09f7f50bc1897ea268389178135322e835ff5ef8692b7b89bab |