Consider the problem of arranging matchsticks so as to form a row of rectangles, as shown below.-----
|--|--|---
Complete the recursive method below, which is designed to return the number of matchsticks needed to form n rectangles.
Public static int matchsticks(int rectangles)
{
If (rectangles == 1) // 1 square can be formed with 6 matchsticks
{
Return 6;
}
Else
{
Return ___________________________
}
}
A) 6 + matchsticks(rectangles - 1) ;
B) 5 + matchsticks(rectangles - 1) ;
C) 6 * rectangles;
D) matchsticks(rectangles + 6) ;
Correct Answer:
Verified
Q26: Consider the getArea method from the textbook
Q27: Would switching the special case order affect
Q28: How many recursive calls to the fib
Q29: _ recursion can occur when a recursive
Q30: If recursion does not have a special
Q32: Consider the method powerOfTwo shown below: public
Q33: Consider the getArea method from the textbook
Q34: Insert the missing code in the following
Q35: Consider the method below, which displays the
Q36: Consider the getArea method from the textbook
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents