

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A homework assignment for a computer science course, csis-385. The assignment involves implementing an algorithm to generate random points in a unit cube, find the two closest points, and generate histogram data from the distances between all pairs of points. Students are also asked to describe an algorithm to find the optimal location of a circle with a given radius to maximize the number of points inside it.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!
See schedule for due date.
Part 1 : Implement an algorithm that randomly generates N points in a unit cube and then finds the two closest points. Output the distance between the two points and the x,y-values of the two points. Part 2: Randomly generate N points, calculate the distance between every pair of points and generate histogram data. Part 3: Describe in words or pseudocode (you do not have to actually implement it) an algorithm that takes a circle of radius R and N points in a unit cube as input and finds the optimal location such that the maximum number of points falls inside the circle.
Part 1: The user should enter the value N, which is the number of random points to generate. The points should be in unit cube, which basically means that the x,y-values of the points must be floating point values between 0 and 1. The points should be stored in some data structure. For example, you could create a Class called Pair, i.e., for storing the x and y values, and the data structure could simply be an array of Pairs. Once the points have been generated use the nested loop we discussed in class to compare and compute the distance between all pairs of points. Keep track of the minimum distance and the two points that achieve that distance. After you’ve compared all pairs, output the minimum distance (a float) and the two points, i.e., two floating point pairs. Be sure to label your output. Part 2: You can copy the code from Part 1, but be sure to create a completely new program. Again, the program should generate N random points in a unit cube. The program should compute the distance between all pairs of points and generate histogram data. A Histogram basically splits the data (all the computed distances) into bins and counts how many numbers are in each bin. Here is an example: Histogram 77 32 65 43 72 26 85 27 9 83 0 33 23 16 8 0 20 40 60 80 100 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1. Bin Ranges Counts
The histogram shows how many numbers (distances) fall into each bin. For example there are 77 distances between 0.0 and 0.1. Similarly, there are 32 distances between 0.1 and 0.2. Your program doesn’t have to create a chart, it just has to generate the data. Your program should output the following data: 0.1 77 0.2 32 0.3 65 0.4 43 … The first number is the bound of the bin and the second number is the count of how many distances fall into the bin. Each bin should increase by a unit of 0.1. Since the points are in a unit cube, it is possible that two points could have a distance of sqrt(2) = 1.414, so your bins should go up to 1.5. Part 3: The user inputs R, which is the radius of a circle. The user inputs N, which is the number of random points to generate in a unit cube. The center of the circle can be placed anywhere in the unit cube. The problem is that you have to find the optimal placement of the circle so that the most points fall within the circle. You can use brute-force computation, i.e., your algorithm doesn’t have to be efficient. Your algorithm should satisfy the 7 properties, but generous partial credit will be given for a good attempt even if its not correct. Write a verbal or pseudocode description of your algorithm and answer the following questions: