From 78402c5f42bc3e3e075b9e81ad72c51c1dea76b9 Mon Sep 17 00:00:00 2001 From: miczal Date: Thu, 11 Aug 2016 20:02:06 +0200 Subject: [PATCH 1/4] [Quicksort]Added shuffling of input --- sorts/quick_sort.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sorts/quick_sort.py b/sorts/quick_sort.py index fa6597041..4e6516cd8 100644 --- a/sorts/quick_sort.py +++ b/sorts/quick_sort.py @@ -10,6 +10,12 @@ For manual testing run: python quick_sort.py """ from __future__ import print_function +from random import shuffle + + +def sort(collection): + shuffle(collection) + return quick_sort(collection) def quick_sort(collection): @@ -58,4 +64,4 @@ if __name__ == '__main__': user_input = input_function('Enter numbers separated by coma:\n') unsorted = [int(item) for item in user_input.split(',')] - print(quick_sort(unsorted)) + print(sort(unsorted)) From 1963a59622b47971b903ed17895e29291ab1229b Mon Sep 17 00:00:00 2001 From: Shashank S Date: Sat, 13 Aug 2016 20:01:22 +0530 Subject: [PATCH 2/4] Update README.md Add description for Selection Sort --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 6d4ac6e41..b643d3686 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,18 @@ __Properties__ ###### View the algorithm in [action][quick-toptal] +## Selection +![alt text][selection-image] + +From [Wikipedia][selection-wiki]: The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), 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) + +###### View the algorithm in [action][selection-toptal] + ## Search Algorithms @@ -87,3 +99,7 @@ Add comments here [merge-toptal]: https://www.toptal.com/developers/sorting-algorithms/merge-sort [merge-wiki]: https://en.wikipedia.org/wiki/Merge_sort [merge-image]: https://upload.wikimedia.org/wikipedia/commons/c/cc/Merge-sort-example-300px.gif "Merge Sort" + +[selection-toptal]: https://www.toptal.com/developers/sorting-algorithms/selection-sort +[selection-wiki]: https://en.wikipedia.org/wiki/Selection_sort +[selection-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Selection_sort_animation.gif/250px-Selection_sort_animation.gif "Selection Sort Sort" From ddec3085ae0be2053c3fa3d11266885169709807 Mon Sep 17 00:00:00 2001 From: Harshil Date: Sun, 14 Aug 2016 00:51:17 +0530 Subject: [PATCH 3/4] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b643d3686..1aaa5898d 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,12 @@ Add comments here ## Ciphers ### Caesar -Add comments here +![alt text][caesar] +In cryptography, a **Caesar cipher**, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques.
+It is **a type of substitution cipher** in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on.
+The method is named after **Julius Caesar**, who used it in his private correspondence.
+The encryption step performed by a Caesar cipher is often incorporated as part of more complex schemes, such as the Vigenère cipher, and still has modern application in the ROT13 system. As with all single-alphabet substitution ciphers, the Caesar cipher is easily broken and in modern practice offers essentially no communication security. +###### Source: [Wikipedia](https://en.wikipedia.org/wiki/Caesar_cipher) [bubble-toptal]: https://www.toptal.com/developers/sorting-algorithms/bubble-sort [bubble-wiki]: https://en.wikipedia.org/wiki/Bubble_sort @@ -103,3 +108,4 @@ Add comments here [selection-toptal]: https://www.toptal.com/developers/sorting-algorithms/selection-sort [selection-wiki]: https://en.wikipedia.org/wiki/Selection_sort [selection-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Selection_sort_animation.gif/250px-Selection_sort_animation.gif "Selection Sort Sort" +[caesar]: https://upload.wikimedia.org/wikipedia/commons/4/4a/Caesar_cipher_left_shift_of_3.svg From 398a6e2e111d101632f169346ba5f0fc5bf60113 Mon Sep 17 00:00:00 2001 From: Harshil Date: Sun, 14 Aug 2016 01:00:20 +0530 Subject: [PATCH 4/4] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1aaa5898d..4a28a8b57 100644 --- a/README.md +++ b/README.md @@ -82,13 +82,17 @@ Add comments here ## Ciphers ### Caesar -![alt text][caesar] +![alt text][caesar]
In cryptography, a **Caesar cipher**, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques.
It is **a type of substitution cipher** in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on.
The method is named after **Julius Caesar**, who used it in his private correspondence.
The encryption step performed by a Caesar cipher is often incorporated as part of more complex schemes, such as the Vigenère cipher, and still has modern application in the ROT13 system. As with all single-alphabet substitution ciphers, the Caesar cipher is easily broken and in modern practice offers essentially no communication security. ###### Source: [Wikipedia](https://en.wikipedia.org/wiki/Caesar_cipher) +### Transposition +In cryptography, a **transposition cipher** is a method of encryption by which the positions held by units of plaintext (which are commonly characters or groups of characters) are shifted according to a regular system, so that the ciphertext constitutes a permutation of the plaintext. That is, the order of the units is changed (the plaintext is reordered).
+Mathematically a bijective function is used on the characters' positions to encrypt and an inverse function to decrypt. +###### Source: [Wikipedia](https://en.wikipedia.org/wiki/Transposition_cipher) [bubble-toptal]: https://www.toptal.com/developers/sorting-algorithms/bubble-sort [bubble-wiki]: https://en.wikipedia.org/wiki/Bubble_sort [bubble-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Bubblesort-edited-color.svg/220px-Bubblesort-edited-color.svg.png "Bubble Sort"