What Will This Function Accomplish?
Well, our goal for the function will be to arrange a list of numbers in ascending order. To accomplish this, we can go through 3 different approaches:
- Bubble Sorting
- Selection Sorting
- Insertion Sorting
However, to understand how to program each one, let’s start by manually sorting a list using each method. For our example, we will use the list [3,1,4,7,6,2,5]. Then, let’s see exactly how we end up with the sorted list using the various methods:
Bubble Sorting Example:
Selection Sorting Example:
Insertion Sorting Example:
Now, let’s program each one in python. To begin, let’s work on the bubble sorting algorithm.
Programming The Various Algorithms:
Not to mention, if you liked this post, please both share with your friends and leave a nice rating! Thanks. 😀