Question: Write a recursive method decrSquares Odd which, when given an int n, returns a LinkedList of all the squares of odd values in the

Write a recursive method decrSquares Odd which, when given an int n, returns a LinkedList of all the squares of odd values in the range [1,n] in decreasing order. A solution that doesn't use recursion will receive little to no credit. For full credit, your function must take no more than O(n) time total. Note: you may create a helper method that does the actual recursion. Please refer to the code handout for a reminder of some LinkedList methods. Some examples: n 123 47 return value of decrSquares Odd (n) [1] [1] [9, 1] [9, 1] [49, 25, 9, 1] // returns a list of the squares of odd values in the range [1,n] in decreasing order PRE: n >= 1. public static LinkedList decrSquares Odd(int n) {
Step by Step Solution
3.36 Rating (152 Votes )
There are 3 Steps involved in it
1 Create a helper method called decrsquaresOddHelper that takes an integer n and a L... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (2 attachments)
663e43041ee70_958988.pdf
180 KBs PDF File
663e43041ee70_958988.docx
120 KBs Word File
