Question: Determining worst case O running time. Please refer to the attached picture. For each of the following algorithm descriptions determine the worst-case O notation running

Determining worst case O running time. Please refer to the attached picture.

Determining worst case O running time. Please refer to the attached picture.

For each of the following algorithm descriptions determine the worst-case O notation running time and briefly justify your answer. A law firm retains forms recording personal information about their n clients (where n is a positive integer). There is one form for each client. The forms are kept in a large filing cabinet and are ordered by the client's last name. Conveniently, the firm has no two clients with the same last name except when the two clients are married to each other. Also conveniently, if a client is married to another client the two clients always have the same last name. Bob, a junior associate, needs to find all the forms for clients who are married to other clients. His plan is to go through the entire filing cabinet one form at a time. Starting with the first form he looks at the client's last name and compares it with the name on the next form. If they are the same then the two clients must be married so Bob takes both forms out of the cabinet. If the two names are different he does nothing. He then looks at the next form in the cabinet and repeats the process until he has looked at all of the forms. It is a year later and Kate has organized the client files by ordering them by SIN. Bob again has to find the forms for all clients that are married to other clients but his old strategy isn't going to work anymore since the forms are no longer ordered by last name. Bob looks at the first file and remembers the last name. He also puts a yellow post-it note on the form so that he can easily find it again. He then goes through all of the forms in the filing cabinet until he either finds another form with the same last name or he gets to the last form in the cabinet. If he finds a form with the same last name he removes that form, moves the post-it note to the next form in the cabinet and removes the form that used to have the post-it note on it (since he has found two forms for clients that are married to each other). If he doesn't find a form with the same name he simply removes the post-it note and puts it on the next form in the cabinet. He repeats this process until the post-it note is on the last form in the filing cabinet

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!