Tour.java Create a Tour data type that represents the sequence of points visited in a TSP tour. Represent the tour as a circular linked list of nodes, one for each point in the tour. Each Node contains two references: one to the associated Point and the other to the next Node in the tour. Each constructor must take constant time. All instance methods must take time linear (or better) in the number of points currently in the tour. To represent a node, within Tour.java, define a nested class Node: private class Node { private Point p; private Node next; } Your Tour data type must implement the following API. You must not add public methods to the API; however, you may add private instance variables or methods (which are only accessible in the class in which they are declared). public class Tour // Creates an empty tour. public Tour() // Creates the 4-point tour a→b→c→d→a (for debugging). public Tour(Point a, Point b, Point c, Point d) // Returns the number of points in this tour. public int size() // Returns the length of this tour. public double length() // Returns a string representation of this tour. public String toString() // Draws this tour to standard drawing. public void draw() // Inserts a point using the nearest neighbor heuristic. public void insertNearest(Point p) // Inserts a point using the smallest increase heuristic. public void insertSmallest(Point p) // Tests this class by calling all constructors and instance methods. public static void main(String[] args)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Tour.java
Create a Tour data type that represents the sequence of points visited in a TSP tour. Represent the
tour as a circular linked list of nodes, one for each point in the tour. Each Node contains two
references: one to the associated Point and the other to the next Node in the tour. Each
constructor must take constant time. All instance methods must take time linear (or better) in the
number of points currently in the tour.
To represent a node, within Tour.java, define a nested class Node:
private class Node {
private Point p;
private Node next;
}
Your Tour data type must implement the following API. You must not add public methods to the
API; however, you may add private instance variables or methods (which are only accessible in the
class in which they are declared).
public class Tour
// Creates an empty tour.
public Tour()
// Creates the 4-point tour a→b→c→d→a (for debugging).
public Tour(Point a, Point b, Point c, Point d)
// Returns the number of points in this tour.
public int size()
// Returns the length of this tour.
public double length()
// Returns a string representation of this tour.
public String tostring()
// Draws this tour to standard drawing.
public void draw()
// Inserts a point using the nearest neighbor heuristic.
public void insertNearest(Point p)
// Inserts a point using the smallest increase heuristic.
public void insertSmallest(Point p)
// Tests this class by calling all constructors and instance methods.
public static void main(String[] args)
Transcribed Image Text:Tour.java Create a Tour data type that represents the sequence of points visited in a TSP tour. Represent the tour as a circular linked list of nodes, one for each point in the tour. Each Node contains two references: one to the associated Point and the other to the next Node in the tour. Each constructor must take constant time. All instance methods must take time linear (or better) in the number of points currently in the tour. To represent a node, within Tour.java, define a nested class Node: private class Node { private Point p; private Node next; } Your Tour data type must implement the following API. You must not add public methods to the API; however, you may add private instance variables or methods (which are only accessible in the class in which they are declared). public class Tour // Creates an empty tour. public Tour() // Creates the 4-point tour a→b→c→d→a (for debugging). public Tour(Point a, Point b, Point c, Point d) // Returns the number of points in this tour. public int size() // Returns the length of this tour. public double length() // Returns a string representation of this tour. public String tostring() // Draws this tour to standard drawing. public void draw() // Inserts a point using the nearest neighbor heuristic. public void insertNearest(Point p) // Inserts a point using the smallest increase heuristic. public void insertSmallest(Point p) // Tests this class by calling all constructors and instance methods. public static void main(String[] args)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY