Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Given the following recursive method, what is the return value of a call to mystery(18)?
public static int mystery(int z){
if (z == 0){
return 2;
}
else{
return z * mystery(z - 3);
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Consider a recursive method below. static void mysteryRecursion (String x) { if (x.length() < 1) { System.out.println(x); } else { System.out.println (x.charAt (0) + " " + x.charAt (x.length () - 1)) ; mysteryRecursion (x.substring (1, x.length () - 1)); What gets printed if I make the method call mysteryRecursion("helloworld");arrow_forwardConsider the following method: public static void method (int x, int y) { if (x < y) { method (x+1, y); System.out.print (x + " "); } } What will happen as the result of calling method (2,6)? (Select all correct answers) output will be 6 5 4 3 2 Program goes to an infinite loop because of errors in recursive calls 5 recursive calls will be made from method (3,6) to method (7,6) output will be 5 4 3 2 method (6, 6) will be called inside of the recursion 4 recursive calls will be made from method (3,6) to method (6,6) method (5, 6) will be called inside of the recursionarrow_forwardThe method is in fact faulty. Give a test input (String) that will make the method to fail -- i.e., it will throw an exception when it is executed with the input).arrow_forward
- what are the values returned for foo(4,2) and foo(5,3) respectively?arrow_forward49, question is in java, thanksarrow_forwardWhich recursive method would return a value of 210 if result(7) was called? Question 1 options: public int result(int a){ if (a == 1){ return a; } else{ return a * result(a - 2); }} public int result(int a){ if (a == 1){ return 1; } else{ return a * result(a - 2); }} public int result(int a){ if (a == 1){ return a + 1; } else{ return a * result(a - 2); }} public int result(int a){ if (a == 1){ return 1; } else{ return a * result(a - 1); }}arrow_forward
- When looking at this code making recursive calls, how would I identify how many recursive calls are being made?arrow_forwardJavaarrow_forwardConsider the following recursive method: public int recursiveMethod (int n) if (n <= 0) return 0; else int smaller = n - 1; return recursiveMethod (smaller) + n (n - 1); What is the integer return of a call recursiveMethod (5)? 36 39 40 44 Next Page Previous Pagearrow_forward
- Question 3 Consider the following recursive method. public static void mystery(int x) { if(x % 3 2) { mystery(x 1); } } if(x % 3 1) { mystery(x - 2); } System.out.print(x + "); == What is output by mystery (13) ? 12 13 13 11 10 8 75421-1 -1 -112457 8 10 11 13 13 12 1 ptsarrow_forwardWrite a statement that calls the recursive method backwardsAlphabet() with parameter starting Letter. 789GHA 10 11 12 13 } TENN 14 15 16 17 18 19 20 21 22 } 23 } } else { } System.out.print(currLetter + "); backwardsAlphabet((char) (currLetter - 1)); public static void main (String[] args) { Scanner scnr = new Scanner(System.in); char startingLetter; startingLetter = scnr.next().charAt(0); /* Your solution goes here */ ▶arrow_forwardWrite a recursive Java method that takes a String as a parameter and returns true if the String is a palindrome. You may assume that the string only contains lower case characters (i.e. no numbers, spaces, punctuation, etc).arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education