Skip to content

Fix typo from 'pidgeonhole' to 'pigeonhole' #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: UTF-8 -*-
#
# Pidgeonhole Sort Algorithm
# Pigeonhole Sort Algorithm
# The All ▲lgorithms library for python
#
# Contributed by: Martmists
# Github: @martmists
#


def pidgeonhole_sort(data):
def pigeonhole_sort(data):
minimum = min(data)
size = max(data) - minimum + 1
holes = [0] * size
Expand Down
12 changes: 9 additions & 3 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ print(binary_search(arr, 3))

# Tree

- Searches
- ### Searches
- [Binary Search](searches/binary-search)
- Sorting
- [Merge Sort](sorting/merge-sort)
- ### Sorting
- [Bubble Sort](sorting/bubble-sort)
- [Cocktail Shaker Sort](sorting/cocktail-shaker-sort)
- [Insertion Sort](sorting/insertion-sort)
- [Merge Sort](sorting/merge-sort)
- [Pigeonhole Sort](sorting/pigeonhole-sort)
- [Selection Sort](sorting/selection-sort)
- [Stooge Sort](sorting/stooge-sort)


# Related
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pidgeonhole Sort
# Pigeonhole Sort

Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements (n) and the length of the range of possible key values (N) are approximately the same. It requires O(n + N) time. It is similar to counting sort, but differs in that it "moves items twice: once to the bucket array and again to the final destination [whereas] counting sort builds an auxiliary array then uses the array to compute each item's final destination and move the item there."

Expand All @@ -11,17 +11,17 @@ pip install allalgorithms
## Usage

```py
from allalgorithms.sorting import pidgeonhole_sort
from allalgorithms.sorting import pigeonhole_sort

arr = [77, 2, 10, -2, 1, 7]

print(pidgeonhole_sort(arr))
print(pigeonhole_sort(arr))
# -> [-2, 1, 2, 7, 10, 77]
```

## API

### pidgeonhole_sort(array)
### pigeonhole_sort(array)

> Returns a sorted array

Expand Down
13 changes: 9 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ print(binary_search(arr, 3))

# Tree

- Searches
- ### Searches
- [Binary Search](https://python.allalgorithms.com/searches/binary-search)
- Sorting
- [Merge Sort](https://python.allalgorithms.com/sorting/merge-sort)

- ### Sorting
- [Bubble Sort](https://python.allalgorithms.com/sorting/bubble-sort)
- [Cocktail Shaker Sort](https://python.allalgorithms.com/sorting/cocktail-shaker-sort)
- [Insertion Sort](https://python.allalgorithms.com/sorting/insertion-sort)
- [Merge Sort](https://python.allalgorithms.com/sorting/merge-sort)
- [Pigeonhole Sort](https://python.allalgorithms.com/sorting/pigeonhole-sort)
- [Selection Sort](https://python.allalgorithms.com/sorting/selection-sort)
- [Stooge Sort](https://python.allalgorithms.com/sorting/stooge-sort)

# Related

Expand Down
6 changes: 3 additions & 3 deletions tests/test_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
insertion_sort,
merge_sort,
selection_sort,
pidgeonhole_sort,
pigeonhole_sort,
stooge_sort,
cocktail_shaker_sort
)
Expand All @@ -24,8 +24,8 @@ def test_insertion_sort(self):
def test_selection_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], selection_sort([7, 3, 2, 19, -44, 1]))

def test_pidgeonhole_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], pidgeonhole_sort([7, 3, 2, 19, -44, 1]))
def test_pigeonhole_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], pigeonhole_sort([7, 3, 2, 19, -44, 1]))

def test_stooge_sort(self):
self.assertEqual([-44, 1, 2, 3, 7, 19], stooge_sort([7, 3, 2, 19, -44, 1]))
Expand Down