Question
C# programming Modify the unordered linked list classes to: 1. Complete the code for the insert(), remove() and removeAll() methods, 2. add the methods min()
C# programming
Modify the unordered linked list classes to:
1. Complete the code for the insert(), remove() and removeAll() methods,
2. add the methods min() and max() to the appropriate clases,
3. demonstrate that your generic classes work for at least int, double, and string,
4. add an insertion sort method that puts the ArrayList in order,
5. Write a program which thoroughly tests these modifications and demonstrates
correctness.
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;
}
}
}
}
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();
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnorderedLinkedListNamespace;
namespace test
{
class Program
{
static void Main(string[] args)
{
UnorderedLinkedList
u.print();
int var = 5;
u.insert(ref var);
var = 12;
u.insert(ref var);
var = 2;
u.insert(ref var);
var = 29;
u.insert(ref var);
u.print();
var = 5;
u.remove(ref var);
u.print();
}
}
}
UnorderedLinkedList.cs
using System;
using LinkedListNamespace;
using LinkedListADTNamespace;
namespace UnorderedLinkedListNamespace
{
public class UnorderedLinkedList
{
public UnorderedLinkedList()
{
}
public override void insert(ref T item)
{
}
public override void removeAll(ref T item)
{
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started