scI 2315 Data Structures Student Name ith no 11. (20 points) Completely re-write
ID: 3602367 • Letter: S
Question
scI 2315 Data Structures Student Name ith no 11. (20 points) Completely re-write the given method using a ‘for' loop w recuraion. public static long mystery (int n) return 1: else return (nmystery (n 1)) 2. (30 points) Please write the Java Algorithm (code segment) that can execute is array expansion. figure 2.5 arr Amay expansion nternaly (a) At the starting point, arr represents 10 infegers; (b) after step 1, original arr ginal ts the same 0 integers; (c)atter steps 2 and 3, arr represents 12 the fest 10 of which are copied from origieal: and (d) after step 4, the 10 integers are avaiable for reclamationExplanation / Answer
11 )
public static long int mystery(int n ) {
int result = 1;
if (n==0)
return result;
for(int i = 1; i<=n ; ++i ) {
result = result * i ;
}
return result;
}
(2) Image is cut, Still
int arr[] = new int[10]; //Represents array of 10 integers
(a)
int orignal[];
orignal = arr;
(b)
Image is cut
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.