Question

3. White the outpot prodased by the following counioxs method when passed eech of the publie atatio void systery (int n) if (

Please show work

0 0
Add a comment Improve this question Transcribed image text
Answer #1
mystery(8);
0 0 0 : 2 4 8

mystery(25);
1 0 0 1 : 3 6 12 25

mystery(46);
0 1 1 1 0 : 2 5 11 23 46

\;\;

Add a comment
Know the answer?
Add Answer to:
Please show work 3. White the outpot prodased by the following counioxs method when passed eech...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the output produced when the following method is passed each of the following lists and...

    Write the output produced when the following method is passed each of the following lists and give the formal code for the problem: public static void mystery1(ArrayList<Integer> list) { for (int i = list.size() - 1; i > 0; i--) { if (list.get(i) < list.get(i - 1)) { int element = list.get(i); list.remove(i); list.add(0, element); } } System.out.println(list); } a. [2, 6, 1, 8] b. [30, 20, 10, 60, 50, 40]

  • I need to make this code access the main method I suppose, but I don't know...

    I need to make this code access the main method I suppose, but I don't know how to make that happen... Help please! QUESTION: Write a method called switchEmUp that accepts two integer arrays as parameters and switches the contents of the arrays. Make sure that you have code which considers if the two arrays are different sizes. Instructor comment: This will work since you never go back to the main method, but if you did, it wouldn't print out...

  • Consider the following method. public static ArrayList<Integer mystery(int n) ArrayList<Integer seg - new ArrayList<IntegerO; for (int...

    Consider the following method. public static ArrayList<Integer mystery(int n) ArrayList<Integer seg - new ArrayList<IntegerO; for (int k = n; k > 0; k--) seq.add(new Integer(k+3)); return seq What is the final output of the following Java statement? System.out.println(mystery(3)); a. [1,2,4,5) b. [2,3,4,5) c. [6,5,4,3] d. [7, 7, 8, 8] e. [7,8,9, 8) O Consider the following method: public static int mystery(int[] arr, int k) ifk-0) return 0; }else{ return arr[k - 1] + mystery(arr, k-1):) The code segment below is...

  • in JAVA 24. Suppose that a class has an overloaded method named add with the following...

    in JAVA 24. Suppose that a class has an overloaded method named add with the following two implementations: double add (int x, double y) { return x + y; } double add (double x, int y) { return x + y + 1; } What, if anything, will be returned by the following method calls? A. add(3, 3.14) B. (3.14, 3) C. add (3, 3) D. add (3.14, 3.14) 29. Here is the code for a recursive method named mystery....

  • 4. Consider the following (almost) complete program: 4includeciostream> using namespace std: la)prototypes here. int main ()...

    4. Consider the following (almost) complete program: 4includeciostream> using namespace std: la)prototypes here. int main () const int size 6 int alsize] 15, 2, 3, 1, 13, 8): int p pma+1 show (a, size) mystery (a, size); show (a, aize) cout<<a [2]+a(51<<endl; cout<<(a+2)-3<<endl: cout<<tp+ a<<endl; cout<<at5<cendl void show (int all, int n) 17 (b) define show void mystery (int all, int n) int temp Eor (int i-0 i<n/2 i++) temp aij alil-aln-i-117 a [n-i-11 temp a) Write prototypes for the...

  • Please answer the question in the picture below and explain your answer. If it helps, the...

    Please answer the question in the picture below and explain your answer. If it helps, the associated coursework is taught in Java. 12. Given the following method, Write the output when the following method is passed each of the following lists: public static void mystery (ArrayList<Integer> list) { for (int i = 0; i < list.size()-1; i++) { int e = list.get(i); list.add (i+2, e + 3); list.remove(i); System.out.println(list); a. [80,60,50,40,30] b. (5,5,5,5,3]

  • Please solve 13 & 14 13. Which of the following is not a legal identifier? A....

    Please solve 13 & 14 13. Which of the following is not a legal identifier? A. firstName B. _name- C. $name D. 1stName 14. Given the code below, what is the output? class Main int a 10 public static void main(Stringt] args) f new Main().print)h public void print) int a = 8; System.out.print(a)i A. 10 B. output is unpredicatable C. 8 D. compilation fails

  • please evaluate the following code. this is JAVA a. class Car { public int i =...

    please evaluate the following code. this is JAVA a. class Car { public int i = 3; public Car(int i) { this.i = i; } } ... Car x = new Car(7), y = new Car(5); x = y; y.i = 9; System.out.println(x.i); b. class Driver { public static void main(String[] args) { int[] x = {5, 2, 3, 6, 5}; int n = x.length; for (int j = n-2; j > 0; j--) x[j] = x[j-1]; for (int j...

  • IV. Function Tracing (20 points) Trace the following program. Show llof your work and the ound...

    IV. Function Tracing (20 points) Trace the following program. Show llof your work and the ound he output in the work including labeled boxes for user-defined functions, calculations, and the output in designated spaces. You should draw a box for each variable and show value updates d the output, Show all of your #include <iostream» using namespace std; void mickey (int sa, int b, int &c) void minnie(int u, int &v, int w); void pluto (int m, int n, int...

  • Question 3 Searching Algorithms [12 marks (4 marks) Define a method that when passed an array...

    Question 3 Searching Algorithms [12 marks (4 marks) Define a method that when passed an array of integers arr and another integer target, returns the last index in arr where target exists and -1 if target isn't found in arr a. b. (4 marks) Provide a trace, in the form of a logic table, of running the following method for 1, 4, 4, 4, 5, 7, 8, 12, 12, 15, 16, 17, 35, 35, 35, 40 arr = target 14...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT