Java Program #21 - Sort Numbers using Bubble Sort in Java
Vložit
- čas přidán 26. 07. 2024
- Java Program to Sort Numbers using Bubble Sort Algorithm | Programming for Beginners
In this video by Programming for Beginners we will learn to write Java Program to Sort Numbers using Bubble Sort Algorithm, using Java Tutorial videos.
This Java program is very important for your Java interview questions or if you are learning Java Programming language as a student.
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order.
This algorithm is suitable for small data sets.
Example:
Input: arr[] = {5, 1, 4, 2, 8}
Output: arr[] = {1, 2, 4, 5, 8}
==========
Java Tutorial for Beginners Playlist:
• Java Tutorial
All Java Programs Playlist:
• Java Programs
We can learn Java Programming language to make web applications or mobile applications for android phones and several other applications for windows, Mac OS and Unix operating systems. Also we can make android applications using Java programming. The concepts covered will be related to basic java and core java that will help you in your next interview questions. You can use any version of Java but all concepts will be same for all java versions. I will be using Java SE 8.
Java is a high-level programming language. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
Java is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain.
Java JDK:
www.oracle.com/java/technolog...
Eclipse IDE:
www.eclipse.org/downloads/
CZcams Gears:
Microphone: amzn.to/3iIk5K3
Mouse: amzn.to/35irmNF
Laptop: amzn.to/3iG0jyD
#JavaProgram #JavaTutorial #Programming #Java
============================
LIKE | SHARE | COMMENT | SUBSCRIBE
Thanks for watching :)
On God, this is the best solution i have seen till now🔥🔥
Thanks. Please subscribe and share with your friends 🙂
Thank You ! Very clearly explained..
Glad it was helpful!
Thank you soo much ! Very well explained brother. Keep it up ! Already Subscribed to you channel. Love from Mumbai
Thank you so much. Love from Pune :)
Thank you so much! hope I can learn more from you sir.
Welcome.. subscribe and share with your friends
the lecture was very good.
thanks
Thank u so much , easily understand explanation..........
You are most welcome
Thanks sir your video helped me so much
Glad it was helpful. Share with your friends 🙂👍
Nice Explanation Sir 🙂
Thanks and welcome
Thank you so much, good explanation ❤️
Welcome 👍🙂
Keep it up ❤️
yes thanks. keep supporting :)
Thank you 😊
You're welcome 😊
Make video for reverse array
Bro, please explain why did you write for loop with i again in the end?
last for loop with i is to print all numbers in array after sorting them, in the format we want, space separated or using commas, etc.
thank you sir
Welcome
Thankx
Welcome
And for descending order?
sir when I tried the code by myself, the code number line 8 of ur code where " j< length -i", where the "i" is used because you said we dont want to swap the last element during the 2nd iteration. but when I tried the code by myself I noticed if I just wrote "j < length" it gives me the same result sorted in ascending order without the last element touched. so is it valid??
If it's working for other combination of numbers than it's valid. Extra checks are being made in your case since the numbers in the end are already sorted after each iteration
How to sort alphanumeric
how about from highest to lowest output? badly need.
for highest to lowest - use condition arr[j-1] < arr[j]
Sir
In if condition why we need to take (arr[ j-1 ] >arr [ j ] ).
Why we should not take ( [ j-1]>[ j ] ) by removing arr before j-1& j
j represents the position and arr[j] represents the number at that position so we have to use arr to compare numbers and not the positions for sorting
Its very hard to understand the for loops.
I undertand what bubble sort is. But the code itself i cant understand
More practice will make your concepts easier