Skip to content

Commit cf295c3

Browse files
committed
Merge branch 'master' of https://github.com/TheAlgorithms/Python
2 parents 4e3ff7c + 398a6e2 commit cf295c3

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

README.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ __Properties__
6161

6262
###### View the algorithm in [action][quick-toptal]
6363

64+
## Selection
65+
![alt text][selection-image]
66+
67+
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.
68+
69+
__Properties__
70+
* Worst case performance O(n^2)
71+
* Best case performance O(n^2)
72+
* Average case performance O(n^2)
73+
74+
###### View the algorithm in [action][selection-toptal]
75+
6476

6577
## Search Algorithms
6678

@@ -70,8 +82,17 @@ Add comments here
7082
## Ciphers
7183

7284
### Caesar
73-
Add comments here
74-
85+
![alt text][caesar]<br>
86+
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.<br>
87+
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. <br>
88+
The method is named after **Julius Caesar**, who used it in his private correspondence.<br>
89+
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.
90+
###### Source: [Wikipedia](https://en.wikipedia.org/wiki/Caesar_cipher)
91+
92+
### Transposition
93+
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).<br>
94+
Mathematically a bijective function is used on the characters' positions to encrypt and an inverse function to decrypt.
95+
###### Source: [Wikipedia](https://en.wikipedia.org/wiki/Transposition_cipher)
7596
[bubble-toptal]: https://www.toptal.com/developers/sorting-algorithms/bubble-sort
7697
[bubble-wiki]: https://en.wikipedia.org/wiki/Bubble_sort
7798
[bubble-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Bubblesort-edited-color.svg/220px-Bubblesort-edited-color.svg.png "Bubble Sort"
@@ -87,3 +108,8 @@ Add comments here
87108
[merge-toptal]: https://www.toptal.com/developers/sorting-algorithms/merge-sort
88109
[merge-wiki]: https://en.wikipedia.org/wiki/Merge_sort
89110
[merge-image]: https://upload.wikimedia.org/wikipedia/commons/c/cc/Merge-sort-example-300px.gif "Merge Sort"
111+
112+
[selection-toptal]: https://www.toptal.com/developers/sorting-algorithms/selection-sort
113+
[selection-wiki]: https://en.wikipedia.org/wiki/Selection_sort
114+
[selection-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Selection_sort_animation.gif/250px-Selection_sort_animation.gif "Selection Sort Sort"
115+
[caesar]: https://upload.wikimedia.org/wikipedia/commons/4/4a/Caesar_cipher_left_shift_of_3.svg

sorts/quick_sort.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
python quick_sort.py
1111
"""
1212
from __future__ import print_function
13+
from random import shuffle
14+
15+
16+
def sort(collection):
17+
shuffle(collection)
18+
return quick_sort(collection)
1319

1420

1521
def quick_sort(collection):
@@ -58,4 +64,4 @@ def quick_sort(collection):
5864

5965
user_input = input_function('Enter numbers separated by coma:\n')
6066
unsorted = [int(item) for item in user_input.split(',')]
61-
print(quick_sort(unsorted))
67+
print(sort(unsorted))

0 commit comments

Comments
 (0)