Skip to content

Create insertionsort.java#247

Open
Gandharvdalal wants to merge 1 commit intomemr5:masterfrom
Gandharvdalal:master
Open

Create insertionsort.java#247
Gandharvdalal wants to merge 1 commit intomemr5:masterfrom
Gandharvdalal:master

Conversation

@Gandharvdalal
Copy link

package sorting;

/**

  • insertionSorting
    */
    public class insertionSorting {

    public static void main(String[] args) {
    int[] a={9,8,7,6,5,4,3,2,1};
    for (int i = 0; i < a.length-1; i++) {
    for (int j = i; j >=0; j--) {
    if (a[j+1]<a[j]) {
    int temp=a[j+1];
    a[j+1]=a[j];
    a[j]=temp;

             }
             
         }
         
     }
     for (int item : a) {
         System.out.print(item+" ");
     }
    

    }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant