Question: public class DriverCode{ public static void main(String[] args){ mystery(100); } public static void mystery(int x){ if(x <5){ return; } else{ System.out.println(x); if(x%3==2){ mystery((int)(x/3)); } else{
public class DriverCode{ public static void main(String[] args){ mystery(100); } public static void mystery(int x){ if(x<5){ return; } else{ System.out.println(x); if(x%3==2){ mystery((int)(x/3)); } else{ mystery((int)(x/2)); } } } }
1. Including the original call to the mystery method, how many times is the method called?
2. What is the correct technical term that describes the code provided in the first IF statement in the mystery method?
3. Consider the following sort methods and the following two methods.
Give the Big-Oh time complexity for each method.
a. Merge sort time complexity:
b. Sequential search time complexity:
c. Selection sort time complexity:
d. Binary search time complexity:
4. Place the methods described above in order of their Big-Oh time complexity, from slowest to fastest growth(i.e fromlowest to highest complexity). As a reminder, here are the methods again:
-Merge sort time complexity:
-Sequential search time complexity:
-Selection sort time complexity:
-Binary search time complexity:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
