Skip to content
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

New algorithm, data structure or puzzle #101

Closed
ZoranPandovski opened this issue Oct 8, 2017 · 4 comments
Closed

New algorithm, data structure or puzzle #101

ZoranPandovski opened this issue Oct 8, 2017 · 4 comments

Comments

@ZoranPandovski
Copy link
Owner

Just make new PR with algorithm implementation. Language doesn't matter.
Follow the structure : https://github.com/ZoranPandovski/al-go-rithms#contribution.

@ramanan12345
Copy link

Python program to implement Pigeonhole Sort */

source code : "https://en.wikibooks.org/wiki/

Algorithm_Implementation/Sorting/Pigeonhole_sort"

def pigeonhole_sort(a):
# size of range of values in the list
# (ie, number of pigeonholes we need)
my_min = min(a)
my_max = max(a)
size = my_max - my_min + 1

# our list of pigeonholes
holes = [0] * size

# Populate the pigeonholes.
for x in a:
    assert type(x) is int, "integers only please"
    holes[x - my_min] += 1

# Put the elements back into the array in order.
i = 0
for count in range(size):
    while holes[count] > 0:
        holes[count] -= 1
        a[i] = count + my_min
        i += 1

a = [8, 3, 2, 7, 4, 6, 8]
print("Sorted order is : ", end = ' ')

pigeonhole_sort(a)

for i in range(0, len(a)):
print(a[i], end = ' ')

@ramanan12345
Copy link

this alogrithm

@ZoranPandovski
Copy link
Owner Author

@ramanan12345 Sure go ahead, add that algorithm following the contribution guide. Thanks

@namish800
Copy link
Contributor

@ZoranPandovski review PR #186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants