Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A magic square is an n * n two dimensional matrix of integers 1 to n 2 such that the sum of every row, column

A magic square is an n * n two dimensional matrix of integers 1 to n2 such that the sum of every row, column and diagonal is the same, i.e, for the case where n=5, the common sum is 65. The simple rule for generating a magic square when n is odd is:

Start with 1 in the middle of the top row; then go up and left, assigning the numbers in increasing order to empty squares; if you fall of the square, imagine the square as tiling the plane and continue; if a square is occupied, move down instead and continue.

a. l have to write a Java program which has a function/method called Magic(int n) that I don't understand how to create and display an n * n magic square for the case when n is odd. I'm not sure how to go about this, can I get a sample code with comments on how to create this

b. Then I have to write a brief analysis for the computing time (function of the upper bound) for the function Magic() I'm not understanding how to write this or what the computing time is.

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

Step: 3

blur-text-image

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions