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

Step 4:  Repeat Step 5 to Step 7 while i < wordlength.
                       Step 5:  Extract character ch from index i.
                       Step 6:  Assign reverseword = ch + reverseword.
                       Step 7:  Increment i by 1.
                       Step 8:  If word = reverseword then go to Step 9, else go to Step 10.
                       Step 9:  Display word “is a palindrome”, and go to Step 11.
                       Step 10: Display word “is not a palindrome”.
                       Step 11: Stop
                    13.  Using recursive algorithm count digits of a number using procedure count(num).
                   Ans.  Step 1:  Start
                       Step 2:  If num = 0 then return 0, else go to Step 3.
                       Step 3:  Return 1 + count(num/10).
                       Step 4:  Stop
                   14.  Write a recursive algorithm to find a .
                                                   b
                   Ans.  Step 1:  Start
                       Step 2:  If b = 1 then return 1, else go to Step 3.
                       Step 3:  Return a × power(a, b-1).
                       Step 4:  Stop

                      Unsolved Questions


                 A.  Tick ( ) the correct answer:
                    1.  Which of the following features of an algorithm indicates that it can be coded to any programming language giving the same result?
                       a.  Finiteness                                  b.  Input
                       c.  Memory                                      d.  Language independence
                    2.  Which of the following is a case that may arises during Big O notation calculation?
                       a.  good case                                   b.  bad case
                       c.  average case                                d.  middle case
                    3.  Which of the following symbols is used to connect relationships between the shapes?
                       a.  Connector                                   b.  Terminal Box
                       c.  Input/Output                                d.  Process
                    4.  The word algorithm originated from a Latin book named ………………… .
                       a.  Abdullah                                    b.  Algorithmi
                       c.  Al-Khwarizmi                                d.  Pseudoalgorithmi
                    5.  Every step in an algorithm follows a ………………… sequence.
                       a.  different                                   b.  infinite
                       c.  logarithmic                                 d.  logical

                 B.  Fill in the blanks:
                    1.  ………………… is a representation of an algorithm in symbols.
                    2.  Developing an algorithm is ………………… consuming.
                    3.  An ………………… algorithm is one which will produce the correct output in minimum time and utilise less memory space.
                    4.  Algorithms must produce the correct output after ………………… number of steps and terminate after that.
                    5.  In ………………… case complexity the function takes the minimum time or the minimum number of steps required for execution.

                 C.  Answer the following questions:
                    1.  Define the following:
                       a.  Algorithm
                       b.  Pseudocode
                       c.  Flowchart


                                                                                                                       421
                                                                            Implementation of Algorithms to Solve Problems  421
   418   419   420   421   422   423   424   425   426   427   428