Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. (30 points.) Consider the abstract class Roundabout, implemented as a Circular linked list, where items range from 0 to 2^{k} 1, depending on their
5. (30 points.) Consider the abstract class Roundabout, implemented as a Circular linked list, where items range from 0 to 2^{k} 1, depending on their position on the circle. The circle has two types of points on it, the red and the blue. The position on circle denotes the number of the red/blue dot. Your goal is to implement the class Roundabout, with its attributes, constructor when there are no points yet on the circle, and the nextBlue(int position) method where, given a position of the red dot, we find the next blue dot in the clockwise order. So for example, the image below shows the roundabout with points [0,245- 1] = [0,31], that is, k=5. The green arrows indicate the next blue item for each red item. We are going in the clockwise ordering, so nextBlue (4) is 7, nextBlue (14) is 20, and nextBlue (29) is 7. Implement the nextBlue (int) method as a part of your Roundabout abstract class, and provide the basic skeleton of the Roundabout class. You should implement the class and the mechanics using a circular linked list (where the last element has a link to the head of the list). You can do your implementation in C++, Java or Python. Note: Do not be confused by green arrows in the figure, they do not indicate links between nodes in the linked list (the links are sequential: 4 links to 7,7 links to 8, 8 links to 10..... , 29 links to 4.) The green arrows are intended to help you understand the functionality of the nextBlue (int) method. k=5 ok 0 34 201= 54 4 29 7 12 20 10 18 14 nextBlue 5. (30 points.) Consider the abstract class Roundabout, implemented as a Circular linked list, where items range from 0 to 2^{k} 1, depending on their position on the circle. The circle has two types of points on it, the red and the blue. The position on circle denotes the number of the red/blue dot. Your goal is to implement the class Roundabout, with its attributes, constructor when there are no points yet on the circle, and the nextBlue(int position) method where, given a position of the red dot, we find the next blue dot in the clockwise order. So for example, the image below shows the roundabout with points [0,245- 1] = [0,31], that is, k=5. The green arrows indicate the next blue item for each red item. We are going in the clockwise ordering, so nextBlue (4) is 7, nextBlue (14) is 20, and nextBlue (29) is 7. Implement the nextBlue (int) method as a part of your Roundabout abstract class, and provide the basic skeleton of the Roundabout class. You should implement the class and the mechanics using a circular linked list (where the last element has a link to the head of the list). You can do your implementation in C++, Java or Python. Note: Do not be confused by green arrows in the figure, they do not indicate links between nodes in the linked list (the links are sequential: 4 links to 7,7 links to 8, 8 links to 10..... , 29 links to 4.) The green arrows are intended to help you understand the functionality of the nextBlue (int) method. k=5 ok 0 34 201= 54 4 29 7 12 20 10 18 14 nextBlue
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started