Question

Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[] b. intj)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A. returns true if b contains less elements than a, false otherwise

The question16 returns true if the length of b is less than length of a. Otherwise false is returned.

Suppose the length of a = 5, length of b = 3 and j = 1.

The initial function call would be:

question16(5,3,1) // returns question16(5,3,2)

question16(5,3,2) //  returns question16(5,3,3)

question16(5,3,3)   // returns true

One more scenario can be checked by connsidering length of a = 3, length of b = 5 and j = 1.

question16(3,5,1) // returns question16(3,5,2)

question16(3,5,2) //  returns question16(3,5,3)

question16(3,5,3) // returns false

Add a comment
Know the answer?
Add Answer to:
Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[]...
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
  • Question 10 (3 points) Which of the following statement is not true? There is a recursive...

    Question 10 (3 points) Which of the following statement is not true? There is a recursive sum method as shown below. When sum (19) is called, summation of all odd numbers less than 19 will be calculated and returned public int sum(int x){ if (x == 0) return 0: else return sum(x-2) + x; The following code segment will throw a testException. This exception has been handled in the way that do nothing but to continue when this exception happens....

  • Question from Object-Oriented Data Structures Using Java 4th Edition Chapter 5 Question 30 Add the following...

    Question from Object-Oriented Data Structures Using Java 4th Edition Chapter 5 Question 30 Add the following methods to the LinkedCollection class, and create a test driver for each to show that they work correctly. Code each of these methods by accessing the internal variables of the LinkedCollection, not by calling the previously defined methods of the class.String toString() creates and returns a string that correctly represents the current collection. 1. Such a method could prove useful for testing and debugging...

  • True False Question 2 (3 points) Given a singly linked list with more than two nodes,...

    True False Question 2 (3 points) Given a singly linked list with more than two nodes, to remove the second node from a linked list with only head reference, assume curr - head, next, you do Set curr.next to head.next Oset head. next to curr.next Set head, next to curr Oset head to curr.next TL th Question 3 (3 points) Given the following singly linked list (a list with four nodes), what will be the value stored at the last...

  • 1) Extend the Binary Search Tree ADT to include a public method leafCount that returns the...

    1) Extend the Binary Search Tree ADT to include a public method leafCount that returns the number of leaf nodes in the tree. 2) Extend the Binary Search Tree ADT to include a public method singleParent-Count that returns the number of nodes in the tree that have only one child. 3) The Binary search tree ADT is extended to include a boolean method similarTrees that receives references to two binary trees and determines whether the shapes of the trees are...

  • Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements...

    Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements DoubleEndedList { private Node front; // first node in list private Node rear; // last node in list private int size; // number of elements in list ////////////////////////////////////////////////// // YOU MUST IMPLEMENT THE LOCATE METHOD BELOW // ////////////////////////////////////////////////// /** * Returns the position of the node containing the given value, where * the front node is at position zero and the rear node is...

  • Modify the LinkedCollection class to be a SortedLinkedCollecton class and see how that effects our implementation...

    Modify the LinkedCollection class to be a SortedLinkedCollecton class and see how that effects our implementation for adding and removing items. You should reference the SortedArrayCollection class provided for how these algorithms should be implemented. What needs to change here? Is it a lot of code or not much? Include a toString method that creates and returns a string that correctly represents the current collection. Include a test driver application that demonstrates your class correctly. //--------------------------------------------------------------------------- // LinkedCollection.java // //...

  • Write a recursive method,     public static Boolean isPalindrome(String s) That returns true if s is...

    Write a recursive method,     public static Boolean isPalindrome(String s) That returns true if s is a palindrome, else false.


  • JAVA 5) What is the output of the following code? int a = 70; boolean b...

    JAVA 5) What is the output of the following code? int a = 70; boolean b = false; if(a >= 70) { System.out.print(1); if(b==true) { System.out.print(2); } } else { System.out.print(3); if(b==false) { System.out.print(4); } } System.out.print(5); 6) What is the output of the code above using these initial values? int a = 43; boolean b = false; 7) The following method is SYNTACTICALLY correct (meaning it will compile). True or false? public boolean method() { int value = 5;...

  • In Java. How would this method look? LinkedBinaryTree.java import java.util.Iterator; public class LinkedBinaryTree implements BinaryTreeADT {...

    In Java. How would this method look? LinkedBinaryTree.java import java.util.Iterator; public class LinkedBinaryTree implements BinaryTreeADT {    private BinaryTreeNode root;    /**    * Creates an empty binary tree.    */    public LinkedBinaryTree() {        root = null;    }    /**    * Creates a binary tree from an existing root.    */    public LinkedBinaryTree(BinaryTreeNode root) {        this.root = root;    }    /**    * Creates a binary tree with the specified element...

  • Write Junit Test for the following class below: public class Turn {    private int turnScore;    private Dice dice;    private boolean isSkunk;    private boolean isDoubleSkunk;    public Turn()    {...

    Write Junit Test for the following class below: public class Turn {    private int turnScore;    private Dice dice;    private boolean isSkunk;    private boolean isDoubleSkunk;    public Turn()    {        dice = new Dice();    }    public Turn(Dice dice) {        this.dice = dice;    }       public void turnRoll()    {        dice.roll();        if (dice.getDie1Value() == 1 || dice.getDie2Value() == 1 && dice.getLastRoll() != 2)        {            turnScore = 0;            isSkunk = true;        }        else if (dice.getLastRoll() == 2)        {            turnScore = 0;            isDoubleSkunk = true; }        else        {           ...

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