Question: These are videos on Recursion https://youtu.be/coG4zDavl40 https://youtu.be/6adwO_ILBXw Recursive Algorithms Assignment 2: Printing Triangles Put all methods within one file called Printing_Triangles_LastName.java. Demonstrate all of


 

These are videos on Recursion

 

https://youtu.be/coG4zDavl40


https://youtu.be/6adwO_ILBXw


Recursive Algorithms Assignment 2: Printing Triangles Put all methods within one file called Printing_Triangles_LastName.java. Demonstrate all of the following methods, each using 6 as a parameter in main(). First 60% Make a recursive method called downTriangle() that takes in a single int parameter, n, and prints out a triangle of asterisks with n rows, as shown below: (If n is less than one, it should print nothing.) ****** ***** **** *** ** * Note: We typically break out of a method returning some type of value that matches the type of the method. (E.g. For method returning an integer, we may write "return 3;" to immediately leave the method.) For void methods, you just type "return;" because you don't have to return anything. Also, you are allowed to use for loops to print out the symbols in the rows, but each new row should involve a new recursive call. Next 20% Make a recursive method called upTriangle() that takes in a single int parameter, n, and prints out a triangle of asterisks with n rows, as shown below: (If n is less than one, it should print nothing.) * ** *** **** ***** ****** Hint: The code for upTriangle() looks very similar to downTriangle() except the recursive calls are in reverse order. Check out Example 2 for an example of a method that runs in reverse. Final 20% Make a recursive method called halfTree() that takes in a single parameter, n, and prints out a tree like the following if n=6: # ### ##### ####### ######### ########### # Note that the character, the number of characters in each row, and the final row are different.

Step by Step Solution

3.50 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

downTriangle This method prints a triangle of asterisks with decreasing rows upTriangle This method ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!