Page 452 - Cs_withBlue_J_C11_Flipbook
P. 452

14.  Write an algorithm to accept any number and print its prime factors. Prime factors of a number are the proper divisors that are
                    prime. Some examples are given below.
                     The prime factors of 24 are 2, 2, 2, 3 as 2 × 2 × 2 × 3 = 24
                     The prime factors of 27 are 3, 3, 3 as 3 × 3 × 3 = 27
                 15.  Write an algorithm to search any number ‘s’ from a single dimensional array ‘a[ ]’ and if found, replace with another number ‘n’.
                    Use linear search algorithm to search the number. Assume that the array is already created.
                 16.  Write an algorithm to find the mean and the standard deviation of ‘n’ numbers stored in a single-dimensional array. Assume that
                    the array is already created.
                     Hint:
                    The mean will be = a[0]+a[1]+a[2]+…..a[n-1]
                    Standard deviation will be calculated as:
                                  2
                                              2
                    √  ( ( a[0] - mean )  + (a[1] - mean)  ………  + (a[n-1] - mean) ))/(n-1)
                                                                  2
                    The mathematical formula is
                                                                      S X i
                                                           X = Average =
                                                                       n
                                                                         n
                                                                         ∑ (X  - X) 2
                                                   σ = Standard Deviation =   i-1  i
                                                                           n-1
                 17.  Assume  two  arrays  are  already  created.  One  stores  the  names  of  10  cities  and  another  stores  the  corresponding  average
                    temperature. Write an algorithm to sort the array in descending order of average temperature using the Bubble Sort technique.
                 18.  Write an algorithm to generate a mirror matrix of a matrix ‘a[][]’ having ‘r’ rows and ‘c’ columns. Assume that the matrix is already
                    created. An example is given for better understanding.
                                              1      2      3           3     2      1
                                              4      5      6           6     5      4
                                              7      8      9           9     8      7
                                              10     11    12          12     11     10
                                                Original matrix          Mirror matrix

                 19.  Write an algorithm to check if a given matrix is a unit matrix or not. A unit matrix is a matrix in which all the principal diagonal
                    elements are equal to 1 and the remaining elements are zero. Assume the matrix is already created. Some examples of the Unit
                    matrix are given below.
                                              1      0     0          1    0     0    0
                                              0      1     0          0    1     0    0
                                              0      0     1          0    0     1    0
                                              3 × 3 Unit matrix       0    0     0    1
                                                                        4 × 4 Unit matrix

                 20.  Write an algorithm to enter any sentence and print the words starting with vowels.
                    For example, if the sentence is: AN APPLE A DAY KEEP DOCTORS AWAY will print the words AN, APPLE, A, AWAY
                 21.  Write an algorithm to enter any word in upper-case and arrange it in ascending order of alphabets without using any standard
                    sorting technique.
                    For example, the word MANGO will be rearranged to AGMNO.
                 22.  Write an algorithm to check if a word entered in upper-case, is a unique word or not. A unique word is a word that has no
                    repeating alphabets like SUN, LIGHT, RAY, PROTINE, WATER, etc.
                 23.  Write an algorithm using the recursive technique to print the highest digit of a number using method highest (number, high).
                 24.  Write a recursive algorithm to convert a binary number to its decimal equivalent using procedure decimal (binary, position).
                 25.  Write a recursive algorithm to check if a given number is an automorphic number or not. An automorphic number is the one that
                                                    2
                    exists at the end of its square. Example 5  = 25. And 25 ends with 5.
                     2
                    6  = 36 and 6 is present at its end.
                      2
                    25  is 625 and 625 has 25 at its end.


                450450  Touchpad Computer Science-XI
   447   448   449   450   451   452   453   454   455   456   457