Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using C + + , This week is all about different sorting methods. The purpose of this lab is to put a vector of coordinates
Using CThis week is all about different sorting methods. The purpose of this lab is to put a vector of coordinates in order. The order is specified by the distance from the centroid of the group of points. For purposes of this lab the selection sort is well adapted to solve this problem and will be the algorithm that you must use. You will be given a vector of points in the xy plane. There is a test bench to verify your code. You will need to implement the following functions. Work through the tests in order, they are designed to gradually build the functionality. You will only have access to the tests in submit mode. In the Coordinate class: unsigned integer Coordinate::getDistanceCoordinate secondPointthe shortest distance between two points is a straight line return the distance between this point and the secondPoint In CoordinateList Coordinate createCenterPointcreate a new Coordinate that is the center of the points listed in the vector this will be a coordinate where x average of all xs and yaverage of all ys unsigned int findNextClosestunsigned int startgiven start, find the index of the next closest coordinate point to center remaining in the list searching from start to the end of the vector return the index of the next closest point void orderListFromCenterusing selection sort algorithm and the functions defined above find the center of mass and store it in the class put the closest point to the center in location in the vector continue to put the points in order one by one by finding the next closest and swapping with whatever is next
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