Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please provide full Java source code for the task along with step-by-step explanation. Using Java Consider the square roots of the numbers from 1 to

image text in transcribed

Please provide full Java source code for the task along with step-by-step explanation.

Using Java Consider the square roots of the numbers from 1 to 100 . Write a program to divide them into two sets A and B having the property that the sum of the numbers in set A is as close as possible to the sum of the numbers in set B. Unlike previous programming assignments, there is no algorithm given in the book for this problem, nor will one be recommended here. Indeed, this is an NP-complete problem, so that finding the best possible answer would seem to require checking all possibilities. On the other hand, there are many heuristics that can lead to good answers, especially if efficient algorithmic tools are used. Depending on the heuristics that you choose, you may need to implement a sorting routine, hash table, search tree, priority queue, trie, or some other data structure that you have learned. Use double-precision floating-point numbers in calculating the square roots and the subset sums. If you make use of certain mathematical facts in the development of your solution, be sure that you state them, along with some justification, in your writeup. It is not necessary for you to provide proofs; something that you think might be true might be a heuristic that leads to a good solution, even if you can't prove it. Your program should first print the difference in the sums of the subsets on the first line, then the numbers (not their square roots) in the set containing 1 on subsequent lines, 15 per line. Your task is not only to design and implement an algorithm for this problem, but also to exercise good judgment in consuming CPU cycles and, as usual, providing a convincing explanation of your method and rationale for important design and implementation decisions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago