Question: Linked Lists 100 points Modify the attached unordered linked list classes to: Complete the code for the insert(), remove() and removeAll() methods, add the methods
Linked Lists
100 points
Modify the attached unordered linked list classes to:
Complete the code for the insert(), remove() and removeAll() methods,
add the methods min() and max() to the appropriate clases,
demonstrate that your generic classes work for at least int, double, and string,
add an insertion sort method that puts the ArrayList in order,
Write a program which thoroughly tests these modifications and demonstrates correctness.
Evaluation:
insert(), remove() and removeAll() methods 20 points
min() and max() methods 20 points
generic data typing 20 points
insertion sort 20 points
Testing 20 points
LinkedListADT.cs//
using System;
namespace LinkedListADTNamespace { public interface LinkedListADT { //insert() method places one item in the list void insert(ref T item); //remove() method removes first instance of item in list void remove(ref T item); //remove() method removes first instance of item in list void removeAll(ref T item); //print() method prints all items in list void print(); } }
UnorderedLinkedList.cs//
using System; using LinkedListNamespace; using LinkedListADTNamespace;
namespace UnorderedLinkedListNamespace { public class UnorderedLinkedList : LinkedList, LinkedListADT { public UnorderedLinkedList() { }
public override void insert(ref T item) { }
public override void removeAll(ref T item) {
} } }
LinkedList.cs//
using System; using LinkedListADTNamespace;
namespace LinkedListNamespace { public abstract class LinkedList { protected class Node { public T value; public Node next; }
protected Node start;
public LinkedList() { start = null; } public abstract void insert(ref T item);
public void remove(ref T item) { }
public abstract void removeAll(ref T item);
public void print() { Node current = start; while (current != null) { Console.WriteLine((T)(current.value)); current = current.next; } } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
