Skip to content

Commit 33eed25

Browse files
authored
Merge pull request thuva4#564 from jigyasak05/master
Bubble sort fixed
2 parents 5021438 + fd6550c commit 33eed25

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from bloomfilter import BloomFilter
2+
from random import shuffle
3+
4+
n = 20 #no of items to add
5+
p = 0.05 #false positive probability
6+
7+
bloomf = BloomFilter(n,p)
8+
print("Size of bit array:{}".format(bloomf.size))
9+
print("False positive Probability:{}".format(bloomf.fp_prob))
10+
print("Number of hash functions:{}".format(bloomf.hash_count))
11+
12+
# words to be added
13+
word_present = ['abound','abounds','abundance','abundant','accessable',
14+
'bloom','blossom','bolster','bonny','bonus','bonuses',
15+
'coherent','cohesive','colorful','comely','comfort',
16+
'gems','generosity','generous','generously','genial']
17+
18+
# word not added
19+
word_absent = ['bluff','cheater','hate','war','humanity',
20+
'racism','hurt','nuke','gloomy','facebook',
21+
'geeksforgeeks','twitter']
22+
23+
for item in word_present:
24+
bloomf.add(item)
25+
26+
shuffle(word_present)
27+
shuffle(word_absent)
28+
29+
test_words = word_present[:10] + word_absent
30+
shuffle(test_words)
31+
for word in test_words:
32+
if bloomf.check(word):
33+
if word in word_absent:
34+
print("'{}' is a false positive!".format(word))
35+
else:
36+
print("'{}' is probably present!".format(word))
37+
else:
38+
print("'{}' is definitely not present!".format(word))

BubbleSort/C/bubblesort.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ printf("Enter number of elements in array\n");
77
scanf("%d",&n);
88
int A[n];
99
printf("Array before sorting\n");
10+
1011
for(i=0;i<n;i++)
1112
{
1213
A[i]=rand()%1000;
1314
printf("%d ",A[i]);
1415
}
1516
printf("\n");
17+
1618
for(i=0;i<n;i++)
1719
{
1820
for(j=n;j>i;j--)
@@ -27,6 +29,7 @@ for(i=0;i<n;i++)
2729
}
2830
}
2931
printf("Array after sorting\n");
32+
3033
for(i=0;i<n;i++) printf("%d ",A[i]);
3134

3235
printf("\n");

0 commit comments

Comments
 (0)