Posts

Bubble Sort Algorithm Using Python

Image
Simple Bubble Sort Algorithm First the question is what is bubble sort algorithm. This is one of the sorting techniques in Data Structures and Algorithms (DSA). In Bubble Sort Algorithm Technique we arrage the program in acending or decending order. In this algorithm iterations occurs until all program turn into acending or descending order (what ever we want to do). You can see below how bubble sort works in the picture below.  Diagram Explaination Lets take a list in python: Iteration 1 1) Check or compare 54 and 23 as we are sorting this in acending order so 23 is smaller then 54 so both numbers swap with each other. 2) Now it will check other two numbers which are 54 and 33. now this time 33 is less than 54 so both the numbers will swap. 3) Now in this step it will swap next two numbers 54 and 15 because 15 is less than 54. and now all the list is sorted as 23, 33, 15, 54 . Iteration 2 Now in the 2nd iteration it will check full list again  1) In this step it will compare ...