In the great city of Atlantis, Prince Val had many sultors. He decided on the following...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In the great city of Atlantis, Prince Val had many sultors. He decided on the following algorithm to determine which person he would marry. First, the suitors would be lined up in order and assigned a number starting with 1. the second would be 2, and so on up to n sultors. Starting with the first, he would count down the line with each letter of his name "V", "a", "I", and then the suitor at "I" would be eliminated from the line. Val would continue counting three more suitors, and eliminating every third one. When Val reached the end of the line, he would resume counting at the beginning of the line. For example, if there were seven suitors, the elimination process would be as follows: Initial list of suitors; Start counting from 1. Suitor #3 eliminated; Suitor #6 eliminated; Suitor #2 eliminated; Suitor #7 eliminated; Suitor #S eliminated; Continue counting at 4. Continue counting at 7. Continue counting at 4. Continue counting at 1. Continue counting at 1. Finally, #1 is eliminated, and suitor #4 is selected. 1234567 124567 12457 1457 145 14 4 Write a program that implements a linked list of nodes to determine the position a suitor should stand if they want to marry the prince, when there are n suitors. Your program should eliminate the suitor by deleting the node corresponding to the suitor for each step of the process. Each sultor also has a name. You should either add the name, a string, as part of the node object or use a parallel HashMap to perform a name lookup. Your program should prompt the user for the number of suitors, each suitor's name, and then after your algorithm runs, print the selected suitor and their name. Be sure to use prompts that make sense to a user who has never run your program before. In the great city of Atlantis, Prince Val had many sultors. He decided on the following algorithm to determine which person he would marry. First, the suitors would be lined up in order and assigned a number starting with 1. the second would be 2, and so on up to n sultors. Starting with the first, he would count down the line with each letter of his name "V", "a", "I", and then the suitor at "I" would be eliminated from the line. Val would continue counting three more suitors, and eliminating every third one. When Val reached the end of the line, he would resume counting at the beginning of the line. For example, if there were seven suitors, the elimination process would be as follows: Initial list of suitors; Start counting from 1. Suitor #3 eliminated; Suitor #6 eliminated; Suitor #2 eliminated; Suitor #7 eliminated; Suitor #S eliminated; Continue counting at 4. Continue counting at 7. Continue counting at 4. Continue counting at 1. Continue counting at 1. Finally, #1 is eliminated, and suitor #4 is selected. 1234567 124567 12457 1457 145 14 4 Write a program that implements a linked list of nodes to determine the position a suitor should stand if they want to marry the prince, when there are n suitors. Your program should eliminate the suitor by deleting the node corresponding to the suitor for each step of the process. Each sultor also has a name. You should either add the name, a string, as part of the node object or use a parallel HashMap to perform a name lookup. Your program should prompt the user for the number of suitors, each suitor's name, and then after your algorithm runs, print the selected suitor and their name. Be sure to use prompts that make sense to a user who has never run your program before.
Expert Answer:
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
Please do this problem in C++. Provide proper commenting (this is crucial) and make sure it compiles and runs well with NO ERRORS. Write a function that takes as a parameter a list or vector and...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Mr. Lawrence had been the manager at Pleasure Sdn Bhd (PSB) since 1 February 2016. His employment was terminated on 30 April 2021 due to disputes with the directors of PSB. After many appeals,...
-
A three-phase generator step-up transformer is rated 26-kV: 345-kV, 850 MVA and has a series impedance of 0.0035 + j0.087 per unit on this base. It is connected to a 26-kV, 800-MVA generator, which...
-
SW Company provides the Equity & Liability information below for analysis, SW Company had net income of $385,200 in 2023 and $339,200 in 2022 Equity and Liabilities Share capital-common (139,100...
-
As you are standing on the platform, a boy in a train moving to the right extends his hand outside the window and releases a ball. In what direction is the ball moving according to (a) you (b) the...
-
Jim Anderson works in the production department of Midwest Steelworks as a machine operator. Jim, a long-time employee of Midwest, is paid on an hourly basis at a rate of $20 per hour. Jim works five...
-
1. A planet is revolving around the sun in an elliptical orbit. The mass of planet is m, angular momentum of planet about sun is L, and length of semi major axis is a and eccentricity is e. Time...
-
Use the following information to answer questions. Viva Electronics produces and sells two products, VE1 and VE2. Viva incurred $168,000 overhead costs in a single cost pool. Viva allocates the...
-
RiverRocks, Inc., is considering a project with the following projected free cash flows: Year Cash Flow (in millions) 0 1 2 3 4 - $49.3 $9.3 $19.4 $19.6 $14.7 The firm believes that, given the risk...
-
Which of the following is an example of a continuous distribution? a. the binomial distribution. b. the exponential distribution. c. the Poisson distribution. d. the Z distribution.
-
Which of the following phases is part of an inventory system? a. planning b. forecasting c. control d. feedback and revisions e. all of the above
-
Using LP to determine the most economical and effective nutritional programme for patients is an application known as a. the transportation problem. b. the product mix. c. the diet problem. d. the...
-
Enounce all the assumptions required for formulating a linear programming problem. You should be able to mention and synthetically describe at least seven of them.
-
What is not an inventory use? a. decoupling function b. storing resources c. irregular supply and demand d. production monitoring e. avoiding stockouts and shortages
-
Sarah and Marcus work for a U.S. furniture maker with locationsoverseas. Their employer decides to send them both to meet theircounterparts at the furniture maker?s location in Italy. To...
-
Cornell and Roberts are partners who agree to admit Stanley to their partnership. Cornell has a capital balance of $80,000 and Roberts has a capital balance of $120,000. Cornell and Roberts share net...
-
On August 12, Mr. and Mrs. Mitchell, the owners of a small secondhand store, attended Alexanders Auction, where they bought a used safe for $50. The safe, part of the Sumstad estate, contained a...
-
Amalgamated Corporation, organized under the laws of State S, sends several traveling salespersons into State M to solicit orders, which are accepted only at the home office of Amalgamated...
-
Dryden, a certified public accountant, audited the books of Elixir, Inc., and certified incorrect financial statements in a form that was filed with the Securities and Exchange Commission. Shortly...
-
Find the value of z 0.10 . Approach We wish to find the z-value such that the area under the standard normal curve to the right of the z-value is 0.10.
-
The scores earned on the mathematics portion of the SAT, a college entrance exam, are approximately normally distributed with mean 516 and standard deviation 116. What scores separate the middle 90%...
-
The heights of a pediatricians three-year-old females are approximately normally distributed, with mean 38.72 inches and standard deviation 3.17 inches. Find the height of a three-year-old female at...
Study smarter with the SolutionInn App