All Algorithms implemented in Python.

Oct. 3, 2018, 3:21 p.m. By: Kirti Bakshi

algorithms

Python is an interpreted high-level programming language for general-purpose programming with a design philosophy that emphasizes code readability, notably making use of significant whitespace.

In this specific article, the focus is put on all algorithms that are implemented in python and are meant for the purpose of Demonstration only.

Also, in the Python standard library There are many implementations of sorts that are much better for performance reasons.

Given below are all the algorithms that are implemented in python:

1- Sort Algorithms:

Given below are the various sorting algorithms that are implemented in python:

1.1 Bubble Sort:

Bubble sort or sinking sort, is a simple sorting algorithm that repeats steps through the list to be sorted, compares each pair of adjacent items and if they are in the wrong order then it swaps them. The pass through the list is repeated until no swaps are needed.

Properties:

  • Worst case performance O(n^2)

  • Best case performance O(n)

  • Average case performance O(n^2)

To View The algorithm In Action: Click Here

1.2 Insertion Sort:

Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms.

Properties:

  • Worst case performance O(n^2)

  • Best case performance O(n)

  • Average case performance O(n^2)

To View The Algorithm In Action: Click Here

1.3 Merge Sort:

Merge sort is a divide and conquer sorting algorithm invented by John von Neumann in 1945 that is efficient, general-purpose, comparison-based.

Properties

  • Worst case performance O(n log n)

  • Best case performance O(n log n)

  • Average case performance O(n log n)

To View The Algorithm In Action: Click Here

1.4 Quick Sort:

Quicksort or partition-exchange sort is an efficient sorting algorithm, that for placing the elements of an array in order serve as a systematic method.

Properties

  • Worst case performance O(n^2)

  • Best case performance O(n log n) or O(n) with three-way partition

  • Average case performance O(n log n)

To View The Algorithm In Action: Click Here

1.5 Selection Sort:

The algorithm works by the division of the input list into two parts: The sublist of items that are already sorted, and the sublist of items that are still remaining to be sorted. In the initial stages, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding in the unsorted sublist the smallest or largest element, swapping it with the leftmost unsorted element and moving the sublist boundaries one element to the right.

Properties

  • Worst case performance O(n^2)

  • Best case performance O(n^2)

  • Average case performance O(n^2)

To View The Algorithm In Action: Click Here

1.6 Shell Sort:

Shell sort is a sorting algorithm that allows the exchange of items that are put far apart. The main idea is to arrange the list of elements so that, every nth element in return gives a sorted list.

Properties

  • Worst case performance O(nlog2 2n)

  • Best case performance O(n log n)

  • Average case performance depends on gap sequence

To View The Algorithm In Action: Click Here

2- Search Algorithms:

Given Below are all the search algorithms that are implemented in python:

2.1 Linear Search:

Linear search that is also known as sequential search is a method for finding a target value within a list. It checks each element of the list sequentially for the target value until a match is found or until all the elements have been searched.

Properties

  • Worst case performance o(n)

  • Best case performance o(1)

  • Average case performance o(n)

2.2 Binary Search:

Binary search, is a search algorithm that within a sorted array finds the position of a target value. It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful.

Properties

  • Worst case performance O(log n)

  • Best case performance O(1)

  • Average case performance O(log n)

  • Worst case space complexity O(1)

2.3 Ciphers:

It is a type of substitution cipher named after Julius Caesar in which each letter in the plain text is replaced by a letter some fixed number of positions down the alphabet.

2.4 Vigenère:

The Vigenère cipher by using a series of interwoven Caesar ciphers based on the letters of a keyword is a method of encrypting alphabetic text. It is a form of poly alphabetic substitution that has been reinvented many times.

2.5 Transposition:

In cryptography, a Transposition Cipher is a method of encryption by which the positions held by units of plain text are shifted according to a regular system, so that the ciphertext constitutes a permutation of the plain text. That is, the order of the units is changed.

For More Information: GitHub