Assignment 4

Consider the ListNode class:
class ListNode<T> {
    T data;
    ListNode<T> next;
    public ListNode(T data){ = data;
        next = null;
    public ListNode(T data, ListNode<T> next){ = data; = next;
Write each of the following pure functions on ListNode.
  1. Test if a list is sorted in ascending order.
  2. Merge two sorted lists.
  3. Test if a list is cyclic.
  4. Remove duplicates from a sorted list.
  5. Test if a list is palindromic.