Page 587 - ComputerScience_Class_11
P. 587

43                  }
                   44                  ar[p+1]=val;

                   45              }
                   46          }
                   47

                   48          void display2()           //display the sorted array
                   49          {

                   50              System.out.println("THE SORTED IS :");
                   51              for(int i=0;i<n;i++)

                   52              {
                   53                  System.out.print(ar[i]+ " ");

                   54              }
                   55          }

                   56
                   57          public static void main()

                   58          {
                   59              Insertion_sort ob=new Insertion_sort();

                   60              ob.accept();
                   61              ob.display1();

                   62              ob.sort();
                   63              ob.display2();
                   64          }//end of main

                   65      }   //end of class

                 The output of the preceding program is as follows:

                       BlueJ: Terminal Window - Java
                   Options

                  ENTER THE SIZE OF ARRAY
                  5
                  ENTER THE ARRAY ELEMENTS
                  7
                  3
                  4
                  79
                  1
                  ORIGINAL ARRAY IS :
                  7 3 4 79 1
                  THE SORTED IS :
                  1 3 4 7 79




                                                                                                Internal Assessment  585
   582   583   584   585   586   587   588   589   590   591   592