Page 114 - Computer science 868 Class 12
P. 114

Step 9:  Repeat Step 10 to Step 11 while k < column_first.
              Step 10: Multiply first_array[i][k] with second_array[k][j] and accumulate the result in array product[i][j].

              Step 11: Increase k by 1.
              Step 12: Increase j by 1.

              Step 13: Increase i by 1.
              Step 14: Display the product matrix, go to Step 16.

              Step 15: Display matrix multiplication is not possible.
              Step 16: Stop.


              3.5.6 Algorithms on String

              Problem 16: Write an algorithm to count how many times a word occurs in a sentence.
              Step 1:  Start.
              Step 2:  Accept sentence in variable sen and search word in search_word.

              Step 3:  Add space at the end of sen.
              Step 4:  Initialise variables count to 0 and word to null.

              Step 5:  Initialise length as sentence length.
              Step 6:  Initialise i to 0.

              Step 7:  Repeat step 8 to Step 13 while i < length.
              Step 8:  Extract each character in ch.

              Step 9:  If ch is equal to space then go to Step 10, else go to Step 12.
              Step 10: If word = search_word then increment the count by 1.
              Step 11: Initialise the word to null, go to Step 13.

              Step 12: Add ch to word.
              Step 13: Increment i by 1.

              Step 14: Display count.
              Step 15: Stop.


              Problem 17: Write an algorithm to delete any word from a sentence.
              Step 1:  Start.
              Step 2:  Accept sentence in variable sen and delete word in del_word.

              Step 3:  Add space at the end of sen.
              Step 4:  Initialise variables word and new_sentence to null.

              Step 5:  Initialise length as sentence_length.
              Step 6:  Initialise i to 0 .
              Step 7:  Repeat Step 8 to Step 13 until i < length.
              Step 8:  Extract each character in ch.





                112112  Touchpad Computer Science-XII
   109   110   111   112   113   114   115   116   117   118   119