Skip to main content

Almost all Searching and Sorting Algorithms for Python 3.x

Reason this release was yanked:

Had some Errors, which were rectified in the newest version

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

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.BinarySearch(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 read them carefully.
  • All the Algorithms return the index of the First Occurence 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.

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.

IsSorted Function Implementation

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

searchsort-0.1.1.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

searchsort-0.1.1-py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page