Last element of each row not random. This algorithm is the same as the purely random algorithm
except when placing an element at the end of the row do not choose randomly but select the only element
that works based on the magic sum. Looking at the 4 Ã— 4 example above, the algorithm would have chosen
6, 10, and 7 randomly but now the only number that will work for the last spot is 11, so simply place that
number in that spot in the array. The implementation of this is going to be similar to the purely random one,
but you will need some addition code or methods to find the number for that last spot of each row. Donâ€™t
forget that it might not always be possible to find that last value. For example, suppose the first 3 random
values put in the magic square array are 2, 3, and 5. Since the magic sum of a 4 Ã— 4 array is 34 we would
need the value 24, but the largest number available is 16.
You should notice that this algorithm finds solutions much faster than the purely random one. In fact, my
purely random program only found solutions to n = 3 cases in a reasonable amount of time. n = 4 would
frequently take more than 100,000,000 tries. But n = 4 works well with this algorithm, finding solutions
quite quickly. The average number of tries necessary for this algorithm to find a magic square is just a little
Pair heuristic. This only works for cases where n is even and I will describe it for the n = 4 case. Recall
that the magic sum for an n = 4 array is 34. Put elements randomly into the rows in pairs where each pair
sums to 17, Â½ the magic sum value. For example, here is a magic square found using that algorithm.
1 12 Â 5 16 15 Â 9 Â 8 Â 2 14 Â 6 11 Â 3 Â 4 Â 7 10 13
In this case the first random value found was 5. It was randomly placed in the first row. Notice this is
different from how the other two algorithms work. 12 is the value that pairs with 5 to get to 17 so we place
12 randomly in one of the remaining open positions. The next random number found was 1 and it was placed
randomly in one of the remaining positions and then its pair, 16, was placed in the only remaining spot in the
This algorithm performs considerably better than the previous algorithm, requiring on average of only
about Â 600,000 tries to find a solution.
I look forward to your thoughts about other general algorithms that will allow us to find magic squares
for even larger nâ€™s.
Below is an outline of the class and the methods that need to be implemented for that class. Do not make
any changes to the classes, variables, names, etc. Just add code. Questions? Start or continue a Discussion.
This assignment is as much about following instructions as it is about programming. Be sure your
methods do exactly what is expected of them and all rules mentioned below and in Canvas and class
discussions are followed.
What follows are general rules that you must follow for this and, as applicable, all other programs you
write in this class. Failure to follow these rules will cost you points.
1. I will eventually post a final test program. A sample test program is already posted to help get you
started. Donâ€™t wait for my final test program to appear to start debugging your program. You should
begin testing with your own test programs. Also, the final test program I post may not be the same test
program I run on your programs. You cannot assume your program is correct just because it works on the
posted test program.
2. Submit your program through Canvas with the name prog1.java. Be sure that my main (test) program is
in a different file from your class(es) and you should not submit my test program. Also, do not make your
classes “public”. If you deviate from any of these rules you will lose points because doing so makes it
much more difficult for me to manage and test your programs.
3. The top of your prog1.java file (and all java code that you turn in to me in the future) should begin with
comments that show: (i) Your name; (ii) Comp 282 and clear mention of what time your class meets; (iii)
The assignment number; (iv) The date the assignment was handed in (which is not necessarily the same
as the due date); (v) A brief description of what is contained in the file.
4. For all Java code you turn in:
a) Choose clear and suggestive variable names.
b) Be sure lines do not wrap to the first column of the next line or disappear off the end of the page.
c) Use comments generously to describe how your methods work. Comments should appear
inside your methods, too â€“ not just at the top. That said, don’t overdo the comments.
d) There should be no more than one return statement in any method.
e) Do not use break statements to exit loops.
f) Do not use global variables. If you are not sure if you are using them, ask.
g) Programs should be 100% your own work, as stated in the syllabus
Get Professional Assignment Help Cheaply
Are you busy and do not have time to handle your assignment? Are you scared that your paper will not make the grade? Do you have responsibilities that may hinder you from turning in your assignment on time? Are you tired and can barely handle your assignment? Are your grades inconsistent?
Whichever your reason is, it is valid! You can get professional academic help from our service at affordable rates. We have a team of professional academic writers who can handle all your assignments.
Why Choose Our Academic Writing Service?
- Plagiarism free papers
- Timely delivery
- Any deadline
- Skilled, Experienced Native English Writers
- Subject-relevant academic writer
- Adherence to paper instructions
- Ability to tackle bulk assignments
- Reasonable prices
- 24/7 Customer Support
- Get superb grades consistently
Online Academic Help With Different Subjects
Students barely have time to read. We got you! Have your literature essay or book review written without having the hassle of reading the book. You can get your literature paper custom-written for you by our literature specialists.
Do you struggle with finance? No need to torture yourself if finance is not your cup of tea. You can order your finance paper from our academic writing service and get 100% original work from competent finance experts.
While psychology may be an interesting subject, you may lack sufficient time to handle your assignments. Don’t despair; by using our academic writing service, you can be assured of perfect grades. Moreover, your grades will be consistent.
Engineering is quite a demanding subject. Students face a lot of pressure and barely have enough time to do what they love to do. Our academic writing service got you covered! Our engineering specialists follow the paper instructions and ensure timely delivery of the paper.
In the nursing course, you may have difficulties with literature reviews, annotated bibliographies, critical essays, and other assignments. Our nursing assignment writers will offer you professional nursing paper help at low prices.
Truth be told, sociology papers can be quite exhausting. Our academic writing service relieves you of fatigue, pressure, and stress. You can relax and have peace of mind as our academic writers handle your sociology assignment.
We take pride in having some of the best business writers in the industry. Our business writers have a lot of experience in the field. They are reliable, and you can be assured of a high-grade paper. They are able to handle business papers of any subject, length, deadline, and difficulty!
We boast of having some of the most experienced statistics experts in the industry. Our statistics experts have diverse skills, expertise, and knowledge to handle any kind of assignment. They have access to all kinds of software to get your assignment done.
Writing a law essay may prove to be an insurmountable obstacle, especially when you need to know the peculiarities of the legislative framework. Take advantage of our top-notch law specialists and get superb grades and 100% satisfaction.
What discipline/subjects do you deal in?
We have highlighted some of the most popular subjects we handle above. Those are just a tip of the iceberg. We deal in all academic disciplines since our writers are as diverse. They have been drawn from across all disciplines, and orders are assigned to those writers believed to be the best in the field. In a nutshell, there is no task we cannot handle; all you need to do is place your order with us. As long as your instructions are clear, just trust we shall deliver irrespective of the discipline.
Are your writers competent enough to handle my paper?
Our essay writers are graduates with bachelor's, masters, Ph.D., and doctorate degrees in various subjects. The minimum requirement to be an essay writer with our essay writing service is to have a college degree. All our academic writers have a minimum of two years of academic writing. We have a stringent recruitment process to ensure that we get only the most competent essay writers in the industry. We also ensure that the writers are handsomely compensated for their value. The majority of our writers are native English speakers. As such, the fluency of language and grammar is impeccable.
What if I don’t like the paper?
There is a very low likelihood that you won’t like the paper.
- When assigning your order, we match the paper’s discipline with the writer’s field/specialization. Since all our writers are graduates, we match the paper’s subject with the field the writer studied. For instance, if it’s a nursing paper, only a nursing graduate and writer will handle it. Furthermore, all our writers have academic writing experience and top-notch research skills.
- We have a quality assurance that reviews the paper before it gets to you. As such, we ensure that you get a paper that meets the required standard and will most definitely make the grade.
In the event that you don’t like your paper:
- The writer will revise the paper up to your pleasing. You have unlimited revisions. You simply need to highlight what specifically you don’t like about the paper, and the writer will make the amendments. The paper will be revised until you are satisfied. Revisions are free of charge
- We will have a different writer write the paper from scratch.
- Last resort, if the above does not work, we will refund your money.
Will the professor find out I didn’t write the paper myself?
Not at all. All papers are written from scratch. There is no way your tutor or instructor will realize that you did not write the paper yourself. In fact, we recommend using our assignment help services for consistent results.
What if the paper is plagiarized?
We check all papers for plagiarism before we submit them. We use powerful plagiarism checking software such as SafeAssign, LopesWrite, and Turnitin. We also upload the plagiarism report so that you can review it. We understand that plagiarism is academic suicide. We would not take the risk of submitting plagiarized work and jeopardize your academic journey. Furthermore, we do not sell or use prewritten papers, and each paper is written from scratch.
When will I get my paper?
You determine when you get the paper by setting the deadline when placing the order. All papers are delivered within the deadline. We are well aware that we operate in a time-sensitive industry. As such, we have laid out strategies to ensure that the client receives the paper on time and they never miss the deadline. We understand that papers that are submitted late have some points deducted. We do not want you to miss any points due to late submission. We work on beating deadlines by huge margins in order to ensure that you have ample time to review the paper before you submit it.
Will anyone find out that I used your services?
We have a privacy and confidentiality policy that guides our work. We NEVER share any customer information with third parties. Noone will ever know that you used our assignment help services. It’s only between you and us. We are bound by our policies to protect the customer’s identity and information. All your information, such as your names, phone number, email, order information, and so on, are protected. We have robust security systems that ensure that your data is protected. Hacking our systems is close to impossible, and it has never happened.
How our Assignment Help Service Works
1. Place an order
You fill all the paper instructions in the order form. Make sure you include all the helpful materials so that our academic writers can deliver the perfect paper. It will also help to eliminate unnecessary revisions.
2. Pay for the order
Proceed to pay for the paper so that it can be assigned to one of our expert academic writers. The paper subject is matched with the writer’s area of specialization.
3. Track the progress
You communicate with the writer and know about the progress of the paper. The client can ask the writer for drafts of the paper. The client can upload extra material and include additional instructions from the lecturer. Receive a paper.
4. Download the paper
The paper is sent to your email and uploaded to your personal account. You also get a plagiarism report attached to your paper.