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 = new 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 : LinkedList, LinkedListADT

{

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!