Question: Write a recursive method findPalindrome(SLL list) that finds whether the contents of a singly linked list form a palindrome. The algorithm is as follows: Base
- Write a recursive method findPalindrome(SLL
list) that finds whether the contents of a singly linked list form a palindrome. The algorithm is as follows: - Base Case: If the list is empty or has one element, return true.
- Recursive Case: If the head and tail have the same contents, apply findPalindrome on a new, shorter list without the head and tail of the original list; if the head and tail do not have the same contents, return false.
Use the SLL.java and SLLNode.java given below: (Please show snapshots of working code and output)
////SLL.java////
public class SLL
public class SLLNode
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
