Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

The Problem

It's the first day of class and you are barely awake. You are hoping to snooze through a typical syllabus day when your new teacher commands you to get up and find the person in the room with the closest birthday to yours.

Luckily, you've taken AP Computer Science already and realize that the key to solving the problem is to sort EVERYONE by their birthday, and then simply look directly to the left and right of you (the birthday that occurs immediately before and after yours) and see which of the two is closer. If you on the end of the list, you have to check with the person at the beginning and vice versa.

In order to solve this problem, you'll get several different classes from an input file. Each class will have several queries. You are required to implement either Merge Sort of Quick Sort in the solution of your assignment.

Input File Specification (birthday.txt)

The input file has a single positive integer, n, on its first line, specifying the number of classes in the input file.

The first line of each input file will have a single positive integer k (1 < k < 1001), representing the number of students in the class. The next k lines will have information about each student. Each line will have the following information separated by spaces: first name, last name, month, day and year of birth.

All names will only contain uppercase alphabetic characters and be no longer than 29 characters long. The month will be represented in its full spelling, in uppercase letters. The day and year will be the appropriate integers. You are guaranteed that all of this information is valid. (Thus, no April 31st will appear, etc.) It is also guaranteed that each full name will be unique. (Namely, no two people in a class will have the exact same first AND last name.)

Following those k lines will be a line containing a single positive integer m (m < k), representing the number of queries for that class. The following m lines will contain the first and last name (separated by a space) of the student in question. (Your goal will be to find the name of the student with the closest birthday to the queried student.)

Output Specification

For each input class, print out a header with the following format:

Class #c:

where c represents the day of the simulation (1 = c = n).

Follow this with a blank line.

The following k lines will answer the queries for that class in the order they were given. For each of these queries, output a single line with the following format:

FIRST2 LAST2 has the closest birthday to FIRST LAST.

where FIRST LAST is the name of the queried student and FIRST2 LAST2 is the name of the student with the closest birthday to FIRST LAST.

To avoid ambiguity, sort the students in the following manner:

1) By birthdate, ignoring the year.

2) To break ties between students with the same exact birthdate, use last name as compared by the strcmp function.

3) To break ties where both #1 and #2 are the same, use the first name, which in these cases, is guaranteed to be different.

To further avoid ambiguity, if both the person who appears right before and right after the queried person are the same number of days away (in birthday) as the queried person, always choose the person who comes AFTER the queried person in the array.

If the queried person is the LAST person in the array, then the person in index 0 will be considered as the person who comes AFTER them. Note: for these purposes, February 29th won't count as an actual day, unless someone in the class has that birthday.

For example, if the queried person's birthday is March 1st, the person right before her has a February 28th birthday and the person right after her as a March 3rd birthday, then the person with the February 28th birthday is considered the closest (1 day way) as compared to the March 3rd birthday (2 days away). BUT, if there IS a February 29th birthday in the class, then that does count as a day.

Put a blank line between the output for each case.

Implementation Restrictions

You must store all the relevant information about a student in an appropriate data structure. You must implement either Merge Sort or Quick Sort. You must follow all the tie-breaking procedures described above.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93092629

Have any Question?


Related Questions in Computer Engineering

Question what is the relationship between programming and

Question : What is the relationship between programming and networking, and do you think that the United States has lost some of its economic advantage in these fields to other parts of the world?

Innbspmid-2009 rite aid hadnbspccc-ratednbsp20-year bonds

In? mid-2009, Rite Aid had? CCC-rated, 20-year bonds outstanding with a yield to maturity of 17.3%. At the? time, similar maturity Treasuries had a yield of 5%. Suppose the market risk premium is 4% and you believe Rite? ...

Wat are three 3 major categories of cyber terrorism and

What are three (3) major categories of cyber terrorism and / or information warfare. Among the chosen categories, determine the one (1) that should be the top priority for the federal government to address.

Suppose mpc is 07 government spending increases by 10

Suppose MPC is 0.7. Government spending increases by $10 billion, and taxes decrease by $5 billion. How would the following items change, and by how much? Disposable income Private saving Public( Government) saving Equil ...

Question suppose user process application p1 of one

Question : Suppose user process (application) P1 of one computer wishes to transfer data (file) to process (application) P2 on another computer in the Internet. What addressing information about P2 is necessary for P1 to ...

Question in relational algebra is the set difference

Question : In relational algebra: is the set difference commutative or not and Why? What is the difference between multivalued and composite attribute? Explain with Example.

Question recently it has become obvious that people are

Question: Recently it has become obvious that people are storing data where it does not belong and people are accessing files and directories that they should not have access to. Elizabeth Montgomery is in charge of the ...

When a developer creates an app should they make it

When a developer creates an app, should they make it backwards compatible, so that the app can be handled by older versions of the operating system? Why or why not?

According to the same national collegiate athletic

According to the same National Collegiate Athletic Association data, the means and standard deviations of eligibility and retention rates (based on a 1,000-point scale) for the 2013-2014 academic year are presented, alon ...

Question a with respect to huffman coding devise a formula

Question : (a) With respect to Huffman Coding, devise a formula to compute the average compression based on the number of characters in a piece of text, n, and the number of unique characters in its alphabet, m. (b) Does ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As