integer stringwhere the integeris the popularity number (1 is most popular) and stringis a female first name. The program is to read the list of names and create an array of objects. It then sorts the array in alphabetical order. The user entersa name, which the program searches for and then reports how common that name is. The program isto use two different search algorithms, a linear search and a binary search. It reports on how many microseconds it takes to find the name using each method. Requirements 1.Each name and popularity number must be stored

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The attached file, CommonFemaleNames.txt, contains the top 1000 female names in the United States. The format is integer stringwhere the integeris the popularity number (1 is most popular) and stringis a female first name. The program is to read the list of names and create an array of objects. It then sorts the array in alphabetical order. The user entersa name, which the program searches for and then reports how common that name is. The program isto use two different search algorithms, a linear search and a binary search. It reports on how many microseconds it takes to find the name using each method.

Requirements

1.Each name and popularity number must be stored in a separate object.

2.The names on the list are all uppercase, but the program must find the name even if it is entered in lower case. Do this by converting the entered name to all caps.

3.It must give an appropriate message if the name entered is not on the list.

4.Both a linear and a binary search are required, for each name entered and the time it takes for each one reported.

5.Either the sort or the binary search must use a recursive method (Hint: a recursive binary search is easier than a recursive sort).

Suggestions1.Chapters8and 19 haveexampleC++code for sorting and searchingarrays.

2.Here is an example of getting the current time in microseconds.auto start_time = chromo::high_resolution_clock::now();ord = namelist.findBinary(name);auto end_time = chrono::high_resolution_clock::now();cout << "Binary search took " << chrono::duration_cast<chrono::microseconds>(end_time -start_time).count() << " microseconds" << endl;

3.Note that on some systems the clock resolution is not fine enough and you may get0 for the time. That is OK.

4.Oneway to organize this is in the UML below.

 

Note: It works best if namePair is an array of pointers to CommonName (My UML creator won’t let me show that).Extra CreditUse quicksort to sort the name objects (5 points)Throw an exception when a name is not found. Handle it in the calling procedure

Name
- namePair: CommonName []
- nextname: int
+ Name()
+ addName(pair: CommonName) : void
+sortNames(): void
+ findLinear(name: string): int
+ findBinary(name: string): int
- findRecursive(name: string, low: int, high: int): void
Note: It works best if namePair is an array of pointers to
CommonName (My UML creator won't let me show that).
CommonName
- ordinal: int
- name: string
+ CommonName(ord: int, aName: string)
+ getOrdinal(): int
+ getName(): string
Transcribed Image Text:Name - namePair: CommonName [] - nextname: int + Name() + addName(pair: CommonName) : void +sortNames(): void + findLinear(name: string): int + findBinary(name: string): int - findRecursive(name: string, low: int, high: int): void Note: It works best if namePair is an array of pointers to CommonName (My UML creator won't let me show that). CommonName - ordinal: int - name: string + CommonName(ord: int, aName: string) + getOrdinal(): int + getName(): string
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education