Question: Consider the following code segment and method makeSquare. int [ ] list = { 1 1 , 1 2 , 1 3 , 1 4
Consider the following code segment and method makeSquare.
int list ;
int square makeSquarelist;
Description: Method makeSquare stores all the values from the D
list array parameter into the smallest possible,
squareshaped, D array.
Precondition: list is a nonempty array.
Postcondition: : Smallest possible square D array is returned.
: All values from list are copied into the d array.
: is stored into any leftover d spaces.
public static int makeSquareint list
int n int Math.sqrtlistlength;
int temp new intnn;
int count ;
for int r ; r n; r
for int c ; c n; c
ifcount list.length
temprc listcount;
count;
else
temprc;
return temp;
Which of the three Postconditions is satisfied by the makeSquare method?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
