CS701-801 - Spring 2019 - Assignment #2Assigned: April 12th, 2019Due: April 26th, 2019No late submissions.Collaboration policy: The goal of homework is to give you practice inmastering the course material. Consequently, you are encouraged to collaboratewith others. In fact, students who form study groups generally dobetter on exams than do students who work alone. However, the assignmentis individual. That is, you must write up each problem solution and/or codeany programming assignment without external assistance, even if you collaboratewith others for discussions. If you are unable to solve a problem, it isyour responsibility to get help from the instructor before the assignment isdue. You are asked to identify your collaborators. If you did not workwith anyone, you must write “Collaborators: none.” If you obtain asolution through research (e.g., on the web), acknowledge your source, butwrite up the solution in your own words. It is a violation of this policyto submit a problem solution that you cannot orally explainto the instructor. No other student may use your solutions; this includesyour writing, code, tests, documentation, etc. It is a violation of this policyto permit anyone other than the instructor and yourself read-access to thelocation where you keep your solutions.1Submission Guidelines: You have to submit your work on Blackboardby the due date. For each of the programming assignments you must use theheader template provided in Blackboard. Make sure that you identify yourselfin the header, and any collaborators. If none, write “none”. Your answersto questions that do not require coding must be included in this headeras well. Your code must follow customary formatting standards, as postedin Blackboard. Format will also be part of your grade. To complete yoursubmission, you have to upload to Blackboard the source file and nothingelse. The submission will not be accepted in any other format.Style and Correctness: Keep in mind that your goal is to communicate.Full credit will be given only to the correct solution which is describedclearly. Convoluted and obtuse descriptions might receive low marks, evenwhen they are correct. Also, aim for concise solutions, as it will save youtime spent on write-ups, and also help you conceptualize the key idea of theproblem.2Assignment 2Grading Rubric:Programcharacteristic Program feature Creditpossible Coding questionsDesign30% Algorithm 30%Functionality30%Program runswithout errors 20%Correct result given 10%Input15%User friendly,typos, spacing 10%Values read incorrectly 5%Output15%Output provided 10%Proper spelling,spacing, user friendly 5%Format10%Documentation: name,collaborators, header, etc. 5%Clarity: comments,indentation, etc. 5%TOTAL 100%1a(25) 1b(25) 2(10) 3(10) 4(10) 5(20) TOTAL(100)3Assignment:The intended usage of a data structure is crucial to choose the most ef-ficient one. Hence, good general-purpose data structures minimize assumptionsabout input characteristics. However, many times data queries can besped up significantly designing application-specific data structures if inputinformation is available.Take for instance the segment intersection decision problem. That is,given a set of segments, decide whether there exists in the set at least one pairof segments that intersect. As we learned, we can solve this problem usinga sweeping technique that is common to computational-geometry algorithms(Chapter 33.2). This algorithm runs in O(n log n) time using Heapsort tosort the segments and a self-adjusting BST to maintain the sweeping linestatus.The i代做CS701-801作业、c/c++编程作业调试、Python/c++,Java课程作业代写、代做course matmplementation of the sweeping mentioned above is quite efficienttaking into account that finding all intersections is known to be in ?(n2).However, a natural question is whether it is possible to decide intersectionin o(n log n) using input information. For instance, the sweeping algorithmstudied assumes that all segments are available from start (off-line). Thus,information such as maximum or minimum coordinates of segment end pointsis easily computable in O(n). Then, one could design an early-stoppingalgorithm that checks first if the range of coordinates has the same order ofmagnitude as n, and if so decides intersection using the sweeping algorithmwith a o(n log n) implementation, or otherwise use the standard O(n log n)implementation.The purpose of this assignment is to implement the described strategyand compare efficiency experimentally drawing conclusions from the resultsobtained. To simplify the task, we will assume that all endpoint coordinatesare different and integer. Your task is the following.1. (a) (25 points) Implement the sweeping algorithm to decide intersectionin a set of segments following the pseudocode in Chapter33. Sort the segments using Heapsort (Section 6.4) and maintainthe sweeping status using a self-adjusting BST (e.g., RB trees(Chapter 13)).(b) (25 points) Implement the sweeping algorithm to decide intersectionin a set of segments following the pseudocode in Chapter 33.Sort the segments using Radix Sort (Section 8.3) and maintain thesweeping status using a van Emde Boas tree (Chapter 20). Given4that all coordinates are different, you can maintain the sweep-linestatus using the y coordinate of the segment endpoint as the key.Remember that to achieve correctness you must use crossproducts. Inother words, you have to follow the sweeping pseudocode in the book.No points for code implementing other algorithms. (You can reuseHeapsort, Radix Sort, BST, and/or vEB tree code if you have it.)Write a method that does the following for an input set (10 points) 2.segments where all endpoint coordinates are different integers. n of-coordinates. Let y -coordinates and the range of x Find the range ofdecide intersection n 10 n calling the method in Part 1b. Else, decide intersection calling themethod in Part 1a.Write a program that does the following for an input value (10 points) 3.. nnon-vertical segments where all end- n Create a “smooth” set of ?. Recall n 10 n that the sweeping algorithm stops after finding the first intersection.So, define the set so that only a few intersect at the endrange to attain a good evaluation of worst-case running x of thetime.non-vertical segments based on the n Create a “sparse” set of ?. n 100 u > smooth set but changing only one segment so thatMake sure this modified segment does not intersect any of theother segments to avoid impact on running time due to new intersections.Call the method in Part 2 with each of these sets and display the ?running time of each in nanoseconds.Run your program and fill the table below (adjust the (10 points) 4.as needed according to your platform to obtain at least 5 n values ofmeasurements).= 10 n nanoseconds2 = 10 n3 = 10 n4 = 10 n5 = 10 n6Smooth setSparse set55. (20 points) What is the best function of n and/or u fitting yourmeasurements? Notice that you are evaluating rate of growth, you arenot being asked which one is faster. Are the results consistent withthe query time of the data structures and algorithms used? Justifyexplaining the running time of each.6转自:http://www.7daixie.com/2019042913633758.html