Insertion sorting is very similar to bubble sorting, even in worst case the running time will be same. The key concept of insertion sort is similar to arrange ...
There are so many sorting technique / algorithm like bubble sort, merge sort, selection sort, quick sort, insertion sort etc. Quicksort is the mostly used ...
Polymorphism is one of the core concepts of any Object Oriented Programing language. Polymorphism is Latin word and its meaning is that an object having a ...
In the world of computer science there are so many concepts and search is the one of the most important things. For example we have telephone directory without ...
Java is Object-Oriented Programming. The core concept of OOPs programming is Encapsulation, Inheritance, Class, Object, Abstraction and Polymorphism. ...
Bubble Sort Java Algorithm:- Key Point is: Take a pair from the collection of item and compare. If they have wrong order swap them. Flow: Consider a ...
In general, Array is a collection of the elements, where elements are of same data type. They are fixed in size. Array gives the random access of the elements ...
Loops in java are also called iteration statements. Basically, there are three types of iterations statement in java. These are while statement do-while ...
Technology is advancing day by day and today the need for a laptop is must for everyone. Mostly, students and businessmen require it to complete their assigned ...
Facebook is one of the best social media platform that provides you social interact with different people. It is also a medium through which you can publicize ...
VAIO:- Although Sony has sold off its famous PC and laptop brand “VAIO” but the brand is still much popular and alive, you can purchase some amazing high ...
Website is a remarkable method to form an online identity. In order to open any website, a complete address of the site is required which is called as URL ...
- « Previous Page
- 1
- …
- 4
- 5
- 6
- 7
- 8
- …
- 10
- Next Page »
just write if(array[j] lesser then array[j+1]) instead of if(array[j] greater then array[j+1]) and it will sort the array in descending order.
I have updated my comment with a code block containing while loop, cheers.
Okay, that’s the code of Bubble sort by using While Loop written in C++.
while(i < 4) { int j = 0; while(j < 4) { if(array[j]>array[j+1])
{
hold=array[j];
array[j]=array[j+1];
array[j+1]=hold;
}
j++;
}
i++;
}
If you have any other questions then let me know, thanks.
yes we can use a while loop.
Welcome
thanks for pointing out.
my pleasure :)
thanks for pointing out !!!