Skip to content
Open
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
20 changes: 13 additions & 7 deletions bubblesort.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#!/usr/bin/env python3

#
# Understanding Bubble Sort with Examples and Code!
# https://youtu.be/WOjc48sVo6E
#
def bubblesort(list):
swapped = True
while swapped:
print
print "New iteration..."
print();
print("New iteration...");
swapped = False
for i in range(len(list)-1):
if(list[i] > list[i+1]):
print "Index: " + str(i) + " - Swap " + str(list[i]) + " with " + str(list[i+1])
print("Index: " + str(i) + " - Swap " + str(list[i]) + " with " + str(list[i+1]))
tmp = list [i]
list[i] = list[i+1]
list[i+1] = tmp
swapped = True
print list
print "Nothing left to swap. Done"
print(list)
print ("Nothing left to swap. Done")
return list

print();
print("Understanding Bubble Sort with Examples and Code! https://youtu.be/WOjc48sVo6E")
print();

l = [5,8,1,4,2]
print l
print(l)

l = bubblesort(l)
print l
print(l)
7 changes: 5 additions & 2 deletions threadtesttool.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@
//
// Comile with:
// gcc -lpthread -o threadtesttool threadtesttool.c
// On Linux, you can compile (optimizations again optional) it with:
// gcc -O3 -o threadtesttool threadtesttool.c -pthread
//

//
// Usage:
// threadtesttool [[num_threads] num_primes_to_find]
// Usually you use this together with time to get a measurement.
// time ./threadtesttool [[num_threads] num_primes_to_find]
//
// OR
//
// nothreadtesttool [[num_threads] num_primes_to_find]
// time ./nothreadtesttool [[num_threads] num_primes_to_find]
//
// Note to create "nothreadtesttool" use:
// ln -s threadtesttool nothreadtesttool
Expand Down