Our Blog

Dive into the latest trends, tutorials and insights in computer science. From AI advancements to coding best practices, our blog brings you a wealth of knowledge for tech enthusiasts and developers alike. Stay ahead of the curve with in-depth articles on programming, software development, cybersecurity and more!

Bubble Sort

Bubble sort is based on the idea of repeatedly comparing pairs of adjacent elements and then swapping their positions if they exist in the wrong order.

In pseudo-code, this would look like:

counter <-- 0
swaps <-- 1
length <-- LEN(list)# this gives the number of elements in the array

WHILE swaps > 0
     swaps <-- 0
     FOR counter <-- 0 TO length-2 DO
          IF list[counter] > list[counter+1] THEN
                temp <-- list[counter]
                list[counter] <--list[counter+1]
                list[counter+1] <-- temp
                swaps <-- swaps + 1                    
          ENDIF
     ENDFOR
ENDWHILE

Categories
Archive