172k views
3 votes
Please solve using raptor software flowchart

The attached file "scrabble.txt" contains words, each stored on a separate line. Develop an algorithm in the form of a Raptor flowchart to compute and display the occurrence frequencies of distinct words found in the file. The output shall be displayed using the following example format, showing that the words ball, barn and bean are found 12, 17 and 5 times, respectively.
ball: 12
barn: 17
bean: 5
Hint: Sort the words stored in the input file "scrabble.txt" . Traverse the array of sorted words, and count the occurrence frequency of each distinct word using two additional arrays, one of the distinct words and one for their occurrence frequencies.

User Rab Ross
by
7.5k points

1 Answer

3 votes

Final answer:

To solve the problem of computing and displaying the occurrence frequencies of distinct words in a file, you can use the Raptor software flowchart. The algorithm involves reading and sorting the words from the file, and then counting the frequencies of each distinct word.

Step-by-step explanation:

To solve the given problem of computing and displaying the occurrence frequencies of distinct words in a file, we can use the Raptor software flowchart. Here is the algorithm:

  1. Read and open the file 'scrabble.txt'.
  2. Create an empty array to store the distinct words.
  3. Create another empty array to store the occurrence frequencies of the distinct words.
  4. Sort the words stored in the 'scrabble.txt' file.
  5. Traverse the sorted array of words.
  6. If the current word is not present in the distinct words array, add it to the array and set its occurrence frequency to 1 in the occurrence frequencies array.
  7. If the current word is already present in the distinct words array, increment its occurrence frequency in the occurrence frequencies array.
  8. Display the distinct words and their occurrence frequencies in the desired format.
User Sangmin
by
7.8k points