In an ancient land, the beautiful princess Eve had many suitors. She decided on the following procedure to determine which suitor she would marry. First, all of the suitors would be lined up one after the other and assigned numbers. The first suitor would be number 1, the second number 2, and so on up to the last suitor, number n. Starting at the first suitor she would then count three suitors down the line (because of the three letters in her name) and the third suitor would be eliminated from winning her hand and removed from the line. Eve would then continue, counting three more suitors, and eliminating every third suitor. When she reached the end of the line she would continue counting from the beginning. For example, if there were 6 suitors then the elimination process would proceed as follows: Suitors: 1 2 3 4 5 6 Suitor 3 will be eliminated! Suitor 6 will be eliminated! Suitor 4 will be eliminated! Suitor 2 will be eliminated! Suitor 5 will be eliminated! To win the princess, stand in position 1. Complete the function selectSuitor(), member of the DoublyList class, to determine in which position a suitor should stand to marry the princess if there are n suitors. A few more details: • The doubly-linked list has each node numbered, starting from the first node as 1, the second at 2, and so on, up to the last node which stores the position of the last suitor. • The easiest way to go around the list is by connecting the first and last node to make this a "circular" list. • Keep traversing the list and deleting every third node until you get to a single node, which holds the position of the winning suitor. • Every time you delete the third node, print the message, "Suitor # will be eliminated!" where # is the suitor's position. • Once you are left with one node, make sure all member variables and pointers in the remaining nodes are updated. Restriction: You may not create any containers (no array, no vector, no linked lists, etc.). All the work must be done in the linked list. The body of the function should be around 20 lines (excluding blank lines, curly brackets, and comments). If your code gets too long, you should revisit it and make it more efficient. Tips on efficiency/readability: • You only need 2 pointers and 2 nested loops. • The body of the function should be around 20 lines (excluding blank lines, curly brackets, and comments). If your code gets too long, you should revisit it and make it more efficient. • Choose descriptive identifiers (do NOT use "curr", or "ptr", or a single letter, except for "i"). To easily debug your code, you should work on Visual Studio. Use the files available in the doubly-linked list chapter and create a list that stores integers from 1 to n (the number of suitors). Once it is working, you can paste your code in CodeCheck.
In an ancient land, the beautiful princess Eve had many suitors. She decided on the following procedure to determine which suitor she would marry. First, all of the suitors would be lined up one after the other and assigned numbers. The first suitor would be number 1, the second number 2, and so on up to the last suitor, number n. Starting at the first suitor she would then count three suitors down the line (because of the three letters in her name) and the third suitor would be eliminated from winning her hand and removed from the line. Eve would then continue, counting three more suitors, and eliminating every third suitor. When she reached the end of the line she would continue counting from the beginning. For example, if there were 6 suitors then the elimination process would proceed as follows: Suitors: 1 2 3 4 5 6 Suitor 3 will be eliminated! Suitor 6 will be eliminated! Suitor 4 will be eliminated! Suitor 2 will be eliminated! Suitor 5 will be eliminated! To win the princess, stand in position 1. Complete the function selectSuitor(), member of the DoublyList class, to determine in which position a suitor should stand to marry the princess if there are n suitors. A few more details: • The doubly-linked list has each node numbered, starting from the first node as 1, the second at 2, and so on, up to the last node which stores the position of the last suitor. • The easiest way to go around the list is by connecting the first and last node to make this a "circular" list. • Keep traversing the list and deleting every third node until you get to a single node, which holds the position of the winning suitor. • Every time you delete the third node, print the message, "Suitor # will be eliminated!" where # is the suitor's position. • Once you are left with one node, make sure all member variables and pointers in the remaining nodes are updated. Restriction: You may not create any containers (no array, no vector, no linked lists, etc.). All the work must be done in the linked list. The body of the function should be around 20 lines (excluding blank lines, curly brackets, and comments). If your code gets too long, you should revisit it and make it more efficient. Tips on efficiency/readability: • You only need 2 pointers and 2 nested loops. • The body of the function should be around 20 lines (excluding blank lines, curly brackets, and comments). If your code gets too long, you should revisit it and make it more efficient. • Choose descriptive identifiers (do NOT use "curr", or "ptr", or a single letter, except for "i"). To easily debug your code, you should work on Visual Studio. Use the files available in the doubly-linked list chapter and create a list that stores integers from 1 to n (the number of suitors). Once it is working, you can paste your code in CodeCheck.
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
Related questions
Question
Please help me in C++. Here are a few requirements:
only using void DoublyList::selecSuitor()
don't forget to update the count
don't forget to delete the node
Thank you !!!
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education