Skip to content

Project to explain the Bubble Sort algorithm in a visual manner.

Notifications You must be signed in to change notification settings

XeelDev/bubble-sort-algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bubble sort algorithm

Description

This project provides a pretty simple and detailed explanation of Bubble sort algorithm.

So, if you were looking for information on this topic, but other sources did not give you a complete understanding, then I hope this project will help you.

Getting Started

Package description

  • An implementation of the algorithm is given in the file BubbleArray.java
  • Мethod "bubbleSorter" performs sorting of the array by the Bubble sort algorithm. The detailed explanation of this method realization is given below.
  • A demonstration of the algorithm work is given in the file BubbleSortDemo.java

Key ideas

Here are the key ideas of the method bubbleSorter realization according to the example below. Look at the illustrations and read the explanation.

  • In the example on the pictures we have array with 6 elements {15, 8, 23, 16, 42, 4}.

  • Algorithm makes iterations in outer loop and inner loop. For each iteration in outer loop the algorithm iterates from the first element to the last in inner loop. The last element is bounded by the “array out border”, that moved by outer loop after its each iteration.

  • At the beginning, in inner loop algorithm iterates for 5 times comparing each element with the next element and swapping them if the next element is less.

  • After each iteration in outer loop, at least one element moves at the end, where it should be.

  • Therefore, step by step each element comes on its place.

'BubbleSortImg1

'BubbleSortImg2

'BubbleSortImg3

Author

XeelDev

About

Project to explain the Bubble Sort algorithm in a visual manner.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages