Java Algorithms for Beginners: Bubble Sort, Improved

preview_player
Показать описание
This tutorial explains a basic Bubble Sort in Java for Beginners, how to improve the basic Bubble Sort algorithm. This example sorts an array of integers in Ascending order. The Bubble Sort works by iterating through the array, comparing neighbors and swapping any elements that are out of order. Two For Loops are used. After each completion of the inner For Loop, one more element is left in the correct order. A second For Loop is used to repeat the logic the correct number of times so all elements in the end are ordered. This video shows how to improve efficiency by reducing the inner For Loop by one with each pass by using the outer For Loop control variable. To show how this is better, a counter is put into the code to count the number of comparisons made.
If there is a particular Algorithm you would like to see, let me know in the comments. Follow and subscribe for more videos on Java Algorithms for Beginners, Java Basics for beginners, and C programming for beginners and check my playlist for similar content.
Рекомендации по теме
join shbcf.ru