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

The output of the preceding program is as follows:
                 Enter the number of lines in the pascals triangle : 6
                         1
                        1 1
                       1 2 1
                      1 3 3 1
                     1 4 6 4 1
                    1 5 10 10 5 1

                                                            Variable Description
                   NAME         TYPE                                       DESCRIPTION

                  n          int          Number of lines
                  f          int          Stores the factorial of a number
                  i          int          Loop Variable
                  j          int          Loop Variable



                   Program 3     Design a class Bubble_binary to sort a given array using Bubble Sort technique and search an
                                 accepted element using Binary Search technique. A main class is to be created to give details
                                 of the constructors and the member methods.
                                 Data Members
                                 int n                           :  To store the array size
                                 int sno                         :   To store the number to be searched
                                 int ar[ ]                       :   To store array elements
                                 Member Methods
                                 Bubble_binary( )                :  To initialise all the data members to 0
                                 void accept( )                  :   To store the size of the array and the elements of  the
                                                                   array
                                 void Bubble_Sort( )             :    To  sort  the  array  using  bubble  sort  technique  and
                                                                   display it
                                 void binary_search( )           :   To accept the user given number and search it using
                                                                   the binary search technique

                   1       import java.util.*;
                   2       class Bubble_Binary

                   3       {
                   4           int n,sno;
                   5           int ar[];

                   6           Bubble_Binary()

                   7           {
                   8               n=sno=0;
                   9           }

                   10
                   11          void accept()




                                                                                                                       443
                                                                                                   Internal Assessment  443
   440   441   442   443   444   445   446   447   448   449   450