Question: Exercise 7. (8 points) Suppose you need to check whether a given text composed by n letters contains all the letters of the alphabet (try

Exercise 7. (8 points) Suppose you need to check whether a given text composed by n letters contains all the letters of the alphabet (try with "The quick brown fox jumps over the lazy dog" !) The text is given into an array A and it terminates with a special end-of-text character. Consider the following two strategies: S1. For each letter, from a to z, check whether there is an occurrence of the letter in A. Return false as soon as you do not find an occurrence. Return true if all letters pass the test. . S2. Create an array B of size 26 where ci corresponds to the i-th letter of the alphabet and where all cells are initialized to false. Traverse array A, for each letter you find, set to true the corresponding cell of Array B. When you reach the special end-of-text character, scan array B to see whether all cells are true, in which case you return true. You return false otherwise. Suppose you count comparisons and variable assignments as primitive operations (the operations indicated in bold). Which one of the two strategies is more efficient in the worst case? Which one is more efficient in the best case? Fill the table below: orst Case (exact) Worst 1g ase (exact g-0 S2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
