Page 259 - C++
P. 259

CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
                                         (Sub Code: 083 Paper Code 91/1 Delhi)

                          NOTE: ​Python does not support function overloading “​as illustrated in
                          the example shown above​”. If you run the code, the second Area(B,H)
                          definition will overwrite/override the first one.

                          (1 mark for each function definition)
                          OR
                          (Full 2 Marks for mentioning Python does not support function
                          overloading)
             3.    (a)    What will be the status of the following list after the First, Second and Third pass                                              3
                          of the bubble sort method used for arranging the following elements in
                          descending order​?
                          Note: Show the status of all the elements after each pass very clearly underlining
                          the changes.
                          152, 104, -100, 604, 190, 204
                   Ans    I Pass
                                152      104     -100     604      190     204
                                152      104     -100     604      190     204
                                152      104     -100     604      190     204
                                152      104     604      -100     190     204
                                152      104     604      190      -100    204
                                152      104     604      190      204     -100

                          II Pass
                                 152      104      604     190      204      -100
                                 152      104      604     190      204      -100
                                 152      604      104     190      204      -100
                                 152      604      190     104      204      -100
                                 152      604      190     204      104      -100

                          III Pass
                                 152      604      190     204      104      -100
                                 604      152      190     204      104      -100
                                 604      190      152     204      104      -100
                                 604      190      204     152      104      -100

                          (1 mark for last set of values of each correct pass)
                   (b)    Write definition of a method ​OddSum(NUMBERS) to add those values in the list of                                     3
                          NUMBERS, which are odd.
                   Ans    def OddSum(NUMBERS):
                              n=len(NUMBERS)
                              s=0
                              for i in range(n):
                                  if (i%2!=0):
                                      s=s+NUMBERS[i]
                              print(s)

                          (½ mark for finding length of the list)
                          ( ½ mark for initializing s (sum) with 0)
                          ( ½ mark for reading each element of the list using a loop)
                          ( ½ mark for checking odd location)
                          ( ½ mark for adding it to the sum)
                          ( ½ mark for printing or returning the value)

                                                     Page #18 of 28
   254   255   256   257   258   259   260   261   262   263   264