Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

voyager2005/java-sorting-techniques

Repository files navigation

java-sorting-techniques

This REPO contains some commonly used array sorting techniques
Please ⭐ this repository if you found it helpful so that more people can benifit from this code πŸ˜ƒ.

Get current updates open issues and pull requests in this repository

This is the selection sort technique. You can find the whole program including accepting the array in this repo.

//selection sort techinique
for(int i = 0 ; i < n-1 ; i++)
{
 //initialization 
 smallest = a[i] ; 
 indexOfSmallest = i ; 
 
 for(int j = i+1 ; j < n ; j++)
 {
 if(a[j] < smallest)
 {
 smallest = a[j]; 
 indexOfSmallest = j ; 
 }
 }
 
 //swpping the array
 temp = a[i];
 a[i] = a[indexOfSmallest];
 a[indexOfSmallest] = temp;
}

image8 1 0

This is the bubble sort technique. You can find the whole program including accepting the array in this repo.

//bubble sort techinique 
for(int i = 0 ; i < n-1 ; i++)
{
 for(int j = 0 ; j < n-i-1 ; j++)
 {
 if(a[j] > a[j+1])
 {
 temp = a[j] ;
 a[j] = a[j+1];
 a[j+1] = temp; 
 }
 }
}

image8 1 1

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /