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
Step: 1
downTriangle This method prints a triangle of asterisks with decreasing rows upTriangle This method ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started