” 辅导CSC 226程序、 写作Python,c/c++程序CSC 226 SUMMER 2020ALGORITHMS AND DATA STRUCTURES IIASSIGNMENT 2 – PROGRAMUNIVERSITY OF VICTORIA1 Programming AssignmentThe assignment is to implement an algorithm to determine if the minimum weight spanning tree of anedge-weighted, connected graph , with no self-loops or parallel edges, is the same when using Primsalgorithm as it is when using Kruskals algorithm. The edge weights in will be real numbers greaterthan 0 and will not necessarily be distinct. A Java template has been provided containing an emptymethod PrimVsKruskal, which takes a single argument consisting of a weighted adjacency matrix for anedge-weighted graph with real number edge weights all greater than 0. The expected behavior of themethod is as follows:Input: An array , of type double, representing an edge-weighted graph.Output: A boolean value which is true if the Prims MST equals the Kruskals MST and falseotherwise.A correct implementation of the PrimVsKruskal class will find the minimum weight spanning tree usingthe textbooks implementation of Prims algorithm (eager version) and the minimum weight spanningtree using the textbooks implementation of Kruskals algorithm and compare. If they are the same itreturns true, otherwise false.You must use The provided Java template as the basis of your submission, and put your implementationinside the PrimVsKruskal method in the template. You may not change the name, return type orparameters of the PrimVsKruskal method. You may add additional methods as needed. You may use anyof the classes provided by the textbook as your code will be run with the algs4.jar file. Most likely youwill use some or all of the following: UF class, IndexMinPQ class, MinPQ class, Edge class, Queue class,etc. The Main method in the template contains code to help you test your implementation by reading anadjacency matrix from a file. You may modify the main method to help with testing, but only thecontents of the PrimVsKruskal method (and any methods you have added) will be marked, since themain function will be deleted before marking begins. Please read through the comments in the templatefile before starting.I foresee three ways of solving this problem, each increasingly more difficult and worth increasinglymore marks. (1) The simplest way to solve this problem is to convert the adjacency matrix into anEdgeWeightedGraph object, running PrimMST and KruskalMST on the graph and then comparing theoutput trees to one another. (2) Another way to solve the problem is to leave the graph as an adjacencymatrix and modifying the code of PrimMST and KruskalMST (inside your PrimVsKruskal class) to workdirectly with the adjacency matrix. You would still generate the two MSTs and compare them. (3) Themost difficult but most efficient way to solve it also involves working directly with the adjacency matrixbut here you build The two trees concurrently, testing the consistency of the trees after adding each edge.We will call this an early detection system, which will potentially recognize if the two trees areunequal before completion of the trees. 辅导CSC 226作业、 写作Python,c/c++,Java程序2 Input FormatThe testing code in the main function of the template reads a graph in a weighted adjacency matrixformat and uses the PrimVsKruskal class to compare the two minimum spanning trees. A weightedadjacency matrix for an edge-weighted graph on vertices is an matrix where entry (,)gives the weight of the edge between vertices and (or 0 if no edge exists). For example,corresponds to the edge-weighted graph below. Note that the weighted adjacency matrix for anundirected graph is always symmetric.The input format used by the testing code in main consists of the number of vertices followed by the weighted adjacency matrix. The graph above would be specified as follows:3 Test DatasetsA collection of randomly generated edge-weighted graphs with positive, real number edge weights willbe used to test Your code. I will provide some example files but you are encouraged to create your owntest inputs to ensure that your implementation functions correctly in all cases.4 Sample RunThe output of a model solution on the graph above is given in the listing below.Reading input values from test1.txt.Does Prim MST = Kruskal MST? true5 Evaluation CriteriaThe programming assignment will be marked out of 25, based on a combination of automated testingand human Inspection. To receive full marks, the algorithm will determine if the MST found by Primequals the MST by Kruskal, while building both trees simultaneously and including some kind of earlyfalse detection technique. That is, to get full marks you cannot simply generate the MSTs then test ifthey are the same. You will need to build both simultaneously, while efficiently checking as they growif the answer is sure to be false, insuring a more efficient best-case run time.Score (/50) Description0 5 Submission does not compile or does not conform to theprovided template.5 15 The implemented algorithm is inaccurate on the testedinputs or only calls PrimMST and KruskalMST.15 20 The implemented algorithm is accurate on all testedinputs and you rewrite Prims and Kruskals to workdirectly on the adjacency matrix.20 25 The implemented algorithm is accurate and has anefficient early false detection scheme.To be properly tested, every submission must compile correctly as submitted, and must be based on theprovided template. You may only submit one source file. If your submission does not compile for anyreason (even Trivial mistakes like typos), or was not based on the template, it will receive at most5 out of 25. The best way to make sure your submission is correct is to download it from conneX aftersubmitting and test it. You are not permitted to revise your submission after the due date, and latesubmissions will not be accepted, so you should ensure that you have submitted the correct version ofyour code before the due date. conneX will allow you to change your submission before the due date ifyou notice a mistake. After submitting your assignment, conneX will automatically send you aconfirmation email. If you do not receive such an email, your submission was not received. If you haveproblems with the submission process, send an email to the instructor before the due date.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。