Question: . ModifythesequentialsearchalgorithmofFigure2.13 so that it works correctly even if the names in the directory are not unique, that is, if the desired name occurs more

.

ModifythesequentialsearchalgorithmofFigure2.13 so that it works correctly even if the names in the directory are not unique, that is, if the desired name occurs more than once. Your modified algorithm should find every occurrence of NAME in the directory and print out the telephone number corresponding to every match. In addition, after all the numbers have been displayed, your algorithm should print out how many occurrences of NAME were located. For example, if NAME occurred three times, the output of the algorithm might look something like this:

528-5638

922-7874

488-2020

A total of three occurrences were located.

. ModifythesequentialsearchalgorithmofFigure2.13 so that it works correctly even if the names in

FIGURE 2.13 Step Operation 1 Get values for NAME, N 2 T,,T ,o and 10000 Set the value of i to 1 and set the value of Found to NO While both (Found NO)and (is 10,000) do Steps 4 through 7 4 If NAME is equal to the th name on the list N then Print the telephone number of that person, T Set the value of Found to YES Else (NAME is not equal to N) Add 1 to the value ofi 8 If (Found NO) then Print the message Sorry, this name is not in the directory Stop 10 The sequential search algorithm

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!