Consider a Person.t structure where a person object has a first name, a last name, a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider a Person.t structure where a person object has a first name, a last name, a date of birth, a profession, and a list of hobbies. • Randomly generate a vector of 1, 000 persons (a skeleton is provided). 3 Create an STL map where Person.t objects are ordered by their last names and then by their first names. Recall that you need to provide an implementation of bool operator <(Person.t &) to do that. You might need to create a structure to be your key type and provide a comparator operator in that structure. • Insert the vector elements in the STL map you created. • Write your own simple BST for the Person t structure. You may use the BST from Lab 7. • Insert the vector elements into your BST. • Compute the overhead of the STL map insertions versus those of the simple BST. Sort the vector first and then repeat the previous experiment. Explain what happened in a comment, skeleton code: #include #include #include #include #include #include #include #include using namespace std struct date int day; int month; int year, date(int d = 0, int m= 0, int y = 0) { day = d; month = m; year = y: } date(const date & d) { day = d.day: month = d.month: year = d.vear. }: date date2(0, 0, 0); struct Person t string first; string last; date d; string profession; vector hobby, Person t(string f= "", stringl = date d1 = date(date2), string pro = "") !! d day = d1.day; d. month = d1.month; d.vear = d1.year, first = f; last = 1; profession = pro; !! int main() cout << "Problem 2:" << endl << end: srand(time(0)); //seed vector hobby; hobby push back("basket"); hobby, push back("running"); hobby. push back("piano"): hobby, push back("drawing"); hobby. push back('reading"); hobby. push back('writing"); hobby. push back('programming! :) "); vector prof. prof.push_back("teacher"); prof push back("lawyer"): prof push back("doctor"); prof push back("engineer"): prof.push back("economist"); prof push back("politician"); lleverything in comments below must be completed vector v; for (int i = 0; i< 1000; i++) { İlint d=; lint m = Ilint y = ; date date(d, m, y): string first = "". for (int i = 0; i< 8; i++) { ifirst =; string last = "". for (int i = 0; i< 8; i++) { ilast =; string pro; pro = proffrand) % 6]; int h = 1 + rand() % 8; Person t p(first, last, date, pro); for (int i = 0; i< h; i++) { i(p.hobby). push back0: } Ily.push back0: } return 0; } Consider a Person.t structure where a person object has a first name, a last name, a date of birth, a profession, and a list of hobbies. • Randomly generate a vector of 1, 000 persons (a skeleton is provided). 3 Create an STL map where Person.t objects are ordered by their last names and then by their first names. Recall that you need to provide an implementation of bool operator <(Person.t &) to do that. You might need to create a structure to be your key type and provide a comparator operator in that structure. • Insert the vector elements in the STL map you created. • Write your own simple BST for the Person t structure. You may use the BST from Lab 7. • Insert the vector elements into your BST. • Compute the overhead of the STL map insertions versus those of the simple BST. Sort the vector first and then repeat the previous experiment. Explain what happened in a comment, skeleton code: #include #include #include #include #include #include #include #include using namespace std struct date int day; int month; int year, date(int d = 0, int m= 0, int y = 0) { day = d; month = m; year = y: } date(const date & d) { day = d.day: month = d.month: year = d.vear. }: date date2(0, 0, 0); struct Person t string first; string last; date d; string profession; vector hobby, Person t(string f= "", stringl = date d1 = date(date2), string pro = "") !! d day = d1.day; d. month = d1.month; d.vear = d1.year, first = f; last = 1; profession = pro; !! int main() cout << "Problem 2:" << endl << end: srand(time(0)); //seed vector hobby; hobby push back("basket"); hobby, push back("running"); hobby. push back("piano"): hobby, push back("drawing"); hobby. push back('reading"); hobby. push back('writing"); hobby. push back('programming! :) "); vector prof. prof.push_back("teacher"); prof push back("lawyer"): prof push back("doctor"); prof push back("engineer"): prof.push back("economist"); prof push back("politician"); lleverything in comments below must be completed vector v; for (int i = 0; i< 1000; i++) { İlint d=; lint m = Ilint y = ; date date(d, m, y): string first = "". for (int i = 0; i< 8; i++) { ifirst =; string last = "". for (int i = 0; i< 8; i++) { ilast =; string pro; pro = proffrand) % 6]; int h = 1 + rand() % 8; Person t p(first, last, date, pro); for (int i = 0; i< h; i++) { i(p.hobby). push back0: } Ily.push back0: } return 0; }
Expert Answer:
Answer rating: 100% (QA)
Here is the completed code for this problem Rewrote the overall structure of the program also added new constructors and getters setters as mentioned ... View the full answer
Related Book For
Vector Mechanics for Engineers Statics and Dynamics
ISBN: 978-0073212227
8th Edition
Authors: Ferdinand Beer, E. Russell Johnston, Jr., Elliot Eisenberg, William Clausen, David Mazurek, Phillip Cornwell
Posted Date:
Students also viewed these programming questions
-
T F T F T F T F T F T T T T T T T T T T Use the given sequence to determine the values of n1 n2, the number of runs G, and the 5% cutoff values from Table A-10.
-
M F F F F M F F M M M F F F F F Use the given sequence to determine the values of n1 n2, the number of runs G, and the 5% cutoff values from Table A-10.
-
Consider the following function main: Int main() { int inStock[10][4]; int alpha [20]; int beta[20]; int gamma[4]= {11,13,15,17}; int delta [10] = {3,5,2,6,10,9,7,11,1,8}; } a) Write the definition...
-
Question 1: Presented below is information related to Al-Arab Company. Its capital structure consists of 80,000 ordinary shares. At December 31, 2020 an analysis of the accounts and discussions with...
-
Define the eight characteristics of quality data.
-
Identify and briefly describe the two general forecasting approaches.
-
Defendant Kenneth Blake was married to Charlene Hinton-Blake, who died in 2012. Three of Hinton-Blakes sisters, including Yvonne Hinton, assisted her with day-to-day care during a four-year period of...
-
Matt Stiner started a delivery service, Stiner Deliveries, on June 1, 2014. The following transactions occurred during the month of June. June 1 Stockholders invested $10,000 cash in the business in...
-
Your client, Gabe, needs to calculate the business part of his real estate taxes. How can Gabe calculate the business part of his real estate taxes? Unset starred question Add the real estate taxes...
-
In early 2016, Doc and Lyn McGee formed the McGee Cake Company. The company produced a full line of cakes, and its specialties included chess cake,* lemon pound cake, and double-iced, double...
-
What are the responsibilities of the Gaming Control Board's Investigations Division? What are the responsibilities of the Gaming Control Board's Enforcement Division? Explain what is meant by...
-
Your company is currently investigating the use of Linux. Your manager has asked you to research the feasibility of using Linux in both the server and workstation environments (from the operating...
-
What is a Linux Distribution and how is the Kali Linux Distribution similar to the Debian Distribution?
-
DISMISSAL OF EMPLOYMENT The applicant, one Nelson Lemo (not real name) was employed by the respondent (Northern Air Maintenance Pty Limited) as a Trainee Aircraft Engineer since 2005. The applicant...
-
5. It takes 3 h 26 min to fill a 2600 L water tank. Determines the length of time, t, in minutes, it will take to fill a 1200 L water tank? (1mark)
-
What does the language have to do with the success of Linux?
-
Having issues getting the program to parse through the data file correctly, how can I fix this issue? Here is the suggestion from my professor... Looking into your code I have some observations: the...
-
In the current year, the City of Omaha donates land worth $500,000 to Ace Corporation to induce it to locate in Omaha and create an estimated 2,000 jobs for its citizens. a. How much income, if any,...
-
In Prob. 3.54, determine the perpendicular distance between portion BG of the cable and the diagonal AD. Problem 3.54: The frame ACD is hinged at A and D and is supported by a cable that passes...
-
A 3-kg uniform arm ABC is supported by a pin at B and is attached to identical springs at A and C. The system is in equilibrium in a vertical plane in the position shown. Knowing that point C is...
-
A cylinder of radius r and mass m rests on two small casters A and B as shown. Initially, the cylinder is at rest and is set in motion by rotating caster B clockwise at high speed so that slipping...
-
Illiterate workers can suffer from embarrassment and fear that keeps them from admitting their problem. Instead, they may cope by asking questions, observing others, and relying on informal...
-
Your company wants to introduce a series of new policies and procedures covering all interactions with external stakeholders. There is a need to ensure that all employees are trained in the same and...
-
Your distribution company operates in several remote locations around the world. Annually, there is an opportunity for regional managers to meet with their counterparts for a weeks training and...
Study smarter with the SolutionInn App