Comments (4)
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 = ' ')
from al-go-rithms.
this alogrithm
from al-go-rithms.
@ramanan12345 Sure go ahead, add that algorithm following the contribution guide. Thanks
from al-go-rithms.
@ZoranPandovski review PR #186
from al-go-rithms.
Related Issues (20)
- easy and efficient nqueen algorithm HOT 4
- Add new algorithm, data structure, cipher, puzzle :rocket: HOT 2
- Merge elements using dynamic programing HOT 3
- Keylogger in Python HOT 3
- Leaders in an Array (Data Structure Problem) HOT 2
- The Bit Game (Bit Manipulation Problem) HOT 3
- Find the index of the first occurrence in a string. (String Problem) HOT 3
- Add new algorithm, data structure, cipher, puzzle rocket HOT 2
- Error in cloning repo HOT 1
- Add new algorithm, data structure, cipher, puzzle rocket HOT 5
- Add new algorithm, data structure, cipher, puzzle :rocket: HOT 1
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted) :rocket:
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted) :loudspeaker:
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted) :loudspeaker: HOT 1
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted) :loudspeaker: HOT 1
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted) :loudspeaker: HOT 1
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted)
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted) HOT 1
- Add new algorithm, data structure, cipher, puzzle (Hacktoberfest accepted) :loudspeaker:
- Merge other and others folder together HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from al-go-rithms.