Page 464 - computer science (868) class 11
P. 464

BOUNDARY ELEMENTS:
              11  22  33
              99        44
              88 77  66
              SUM OF OUTER ROW AND OUTER COLUMN =440
                                                         Variable Description
                 NAME         TYPE                                       DESCRIPTION
               num[][]     int[][]      Array elements
               m           int          Number of rows

               n           int          Number of columns
               i           int          Loop Variable
               j           int          Loop Variable
               x           int          Size of Array
               b[]         int[]        Stores the Array in one-dimensional array

               s           int          Sum of boundary elements




                Program 10     Design a class “Selection_Sort” that inputs an array from the user and sorts it in ascending
                               order using selection sort technique. A class is declared to give the details of the constructor
                               and member methods.
                               Data Members
                               int ar[]                        :  Integer array to store array members
                               int n                           :  To store the length of the array
                               Member Methods
                               Selection_Sort()                :  Constructor to initialise n to 0
                               void readlist()                 :   To accept the value of n and array elements from the
                                                                 user
                               int Index_Of_Min(int startindex)   :  To return the index position of the smallest value
                               void sort()                     :   To sort the array in ascending  order  using  selection
                                                                 sort technique
                                void display()                 :  To display the sorted array
                               Write the main method to call the methods and run the program.

                 1       import java.util.*;
                 2       class Selection_Sort

                 3       {
                 4           int ar[],n;
                 5           Scanner sc=new Scanner(System.in);

                 6           Selection_Sort()

                 7           {
                 8               n=0;
                 9           }

                10


                462462  Touchpad Computer Science-XI
   459   460   461   462   463   464   465   466   467   468   469