💡 103. Merge sort in Perl 6

Welcome to another sorting episode, this time we’ll talk about Merge sort in Perl 6. In Merge sort, you first split the data into halves until the pieces become atomic (in the original meaning of the word), that is either each piece contains a single element, or, after the current split, the second part contains … Continue reading “💡 103. Merge sort in Perl 6”

💡 102. Insertion sort in Perl 6

Today, we are investigating the Insertion sort algorithm and its possible implementation in Perl 6. The algorithm’s complexity is O(n2), but it is a good candidate to practice some Perl 6. The idea is simple. You find the minimum value in the array and put it to the first position. Then you scan the data … Continue reading “💡 102. Insertion sort in Perl 6”

💡 101. Quick sort in Perl 6

Today, let’s look at another, and presumably the most well known method of sorting data, Quick sort. The algorithm requires you to select the so-called pivot, one of the element from the data, and split the rest in two parts: the elements less than the pivot, and the elements more or equals to the pivot. … Continue reading “💡 101. Quick sort in Perl 6”

💡 100. Bubble sort in Perl 6

Hey everyone, let’s implement some algorithms in Perl 6. The first one will be the classical Bubble sort. In essence, you scan the data from left to right and swap the two adjacent items if they are not ordered properly yet. Repeat until the whole data list is ordered. Here’s the initial straightforward implementation: sub … Continue reading “💡 100. Bubble sort in Perl 6”