QuestionDetails: Write a code in java. public static lp reverse(lp head) If the
ID: 3612861 • Letter: Q
Question
QuestionDetails: Write a code in java. public static lp reverse(lp head) If the input is empty return null otherwise use a recursivecall to reverse the list.head.rest. then use the append function to add head.first to the end of the reversed list. The second argument of appendis a list not a number.But you can make a list of lengthone,containing only the number head.first. then you can use appendto add this list to the end of another list The user should see input positive integers 5,3,8,2, reverse 2 8 9 5 QuestionDetails: Write a code in java. public static lp reverse(lp head) If the input is empty return null otherwise use a recursivecall to reverse the list.head.rest. then use the append function to add head.first to the end of the reversed list. The second argument of appendis a list not a number.But you can make a list of lengthone,containing only the number head.first. then you can use appendto add this list to the end of another list The user should see input positive integers 5,3,8,2, reverse 2 8 9 5 QuestionDetails: Write a code in java. public static lp reverse(lp head) If the input is empty return null otherwise use a recursivecall to reverse the list.head.rest. then use the append function to add head.first to the end of the reversed list. The second argument of appendis a list not a number.But you can make a list of lengthone,containing only the number head.first. then you can use appendto add this list to the end of another list The user should see input positive integers 5,3,8,2, reverse 2 8 9 5Explanation / Answer
public static Ip reverse(Iphead) { if(head==null) { returnnull; } Iptemp=reverse(head.getRest()); if(temp!=null) { append(head.first,temp); returntemp; } else { return newIp(head.first, null); }}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.