Write a class called List that implements linked lists of integers.

All functions must be implemented using recursion. No loops of any kind are allowed.

The lists are always kept in increasing order. You may assume that the argu- ments to each function are already in increasing order.

Implement the functions shown below.

using System;

public class List {

class Node {
public int item;
public Node next;
}

Node first;

public List() {
first = null;
}

static Node Add(Node node, int item) {
// Helper function.
}

public void Add(int item) {
// Adds item to a list, putting in the right place so that the list
// remains in increasing order.
}

static int Length(Node node) {
// Helper function.
}

public int Length() {
// Returns the length of the list.
}

static int Count(Node node, int item) {
// Helper function.
}

public int Count(int item) {
// Returns the number of occurrences of item.
}

static int Sum(Node node) {
// Helper function.
}

public int Sum() {
// Returns the sum of the numbers in the list.
}

static Node Filter(Node node, Func test) {
// Helper function.
}

public static List Filter(List list, Func test) {
// Returns a new list containing the items from list for which the function
// test returns true.
}

static Node Copy(Node node) {
// Helper function.
}

public List Copy() {
// Makes a copy of the list (with all new nodes).
}

static Node Merge(Node node1, Node node2) {
// Helper function.
}

public static List Merge(List list1, List list2) {
// Merges two lists using the merge algorithm. Must run in linear times.
}

static string ToString(Node node) {
// Helper function.
}

public override string ToString() {
// Returns a string representation of a list that looks like [1,2,4,5,7].
// The empty list looks like [].
// A list with one item looks like [2].
}
}
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.