Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use simple C++ codes. and the correct one please. Sequential Search Learning Objectives: Review how to read in data from a file Review how

image text in transcribed

Please use simple C++ codes. and the correct one please.

Sequential Search Learning Objectives: Review how to read in data from a file Review how to instantiate and store a collection of objects Review how to compare two objects based on a "primary key" Measure the computational complexity of an algorithm based on the number of loop iterations In this program, you will implement the classic (but not very interesting) Sequential Search algorithm. What you need to do: , Your program should accept a single command-line parameter, which is the name of the file to read. If the user forgets the command-line parameter, or if the file cannot be found your program should report an appropriate error message . Here is an example of what the input he looks like: 5 Oogle Tiwe 2029 Analyst 2013 Beint itywnipo 54 24 consierge2019 Boswell Tydedu 75 programmer | 2011 Zilbo Duhen 67,59 Consultant 2013 Nodock Reso77 48 | Consultant|2016 57 54 The first line contains a single integer, n, indicating how many lines of data will follow, in this case n=5. The next n lines hold information about individual employees of a fictional organization. Each line shows, in this order, the Name, ID number, age, job title, hire date of an employee. The fields are separated by vertical bars (pipes). You'll want to design a new class I call minemployee that can accommodate all these fields, and instantiate a new mployee object for each line of the input. Store them all in an array or list of some kind After you parse all the lines of data, the next line will be a single integer, a indicating how many queries will follow. (In the above example, q=2.) A query is an ID number of one of the employees in your list. For each query, your program should loop through the list of employees and find the employee associated with the given ID. . During the testing/debugging phase, your program should print out: 1. the name, age, job title, and hire date of each individual that is looked up 2. how many comparisons you had to perform to find that individual 3. After all the queries are finished print out the average number of comparisons that your program had to do, per query. HINT: I suggest using a double variable to store the average . For the sample input shown above, your program should output something similar to this: FOUND: NA: zilbo buhene, Age: 59, 35: consultant, Hired: 2013 at index 3 after comparisons. FOUND: Nane: nellt rywipo, Age: 24, Job: consterge, fred: 2019 at index 1 after 2 comparisons. Dore! Average agunt of work per query: 3.e comparisons. Test Cases For testing/debugging, use this file as your input, or make your own your program should output something like this Minimize File Preview 0 - ZOOM + | FOUND: Name: Belwit Xuwokadi, Age: 32, Job: Project Manager, Hired: 2005 at index 79 after 30 comparisons. FOUND: Name: Boswell Byxu, Age: 36, Job: Bookkeeper, Hired: 1995 at index 22 after 23 comparisons. FOUND: Name: Oogle Tiweki, Age: 29, Job: Analyst, Hired: 2003 at index 0 after I comparisons. : : at index 65 after 66, Age: 53, Job: Bookkeeper, Hired: 1993 . FOUND: Name: Quendor Lotatyvu, Age: 53, Job: Engineer, Hired: 1990 at index 75 after 76 comparisons Done! Average amount of work per query: 49.2 comparisons. ou're confident your program is working, comment-out the print statements (except for the "average output at the end), and try this larger input where n=10,000. The average should be something around In general, the average complexity of sequential search is around n/2 for large inputs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago

Question

Demonstrate how to use the Gaps Model for diagnosing and

Answered: 1 week ago