Can someone help me write an algorithm to implement the Reverse method. Please include any test cases you would write to prove that software works. I am a newbie.
public class SimpleLinkedList<T>
{
public INode<T> Nodes { get; private set; }
private INode<T> _lastNode;
public void Add(INode<T> node)
{
if (Nodes == null)
{
Nodes = node;
_lastNode = node;
return;
}
_lastNode.Next = node;
_lastNode = node;
}
public void Print()
{
var n = Nodes;
while (n != null)
{
Console.WriteLine(n.Value);
n = n.Next;
}
}
public void Reverse()
{
}
}
thanks in advance
public class SimpleLinkedList<T>
{
public INode<T> Nodes { get; private set; }
private INode<T> _lastNode;
public void Add(INode<T> node)
{
if (Nodes == null)
{
Nodes = node;
_lastNode = node;
return;
}
_lastNode.Next = node;
_lastNode = node;
}
public void Print()
{
var n = Nodes;
while (n != null)
{
Console.WriteLine(n.Value);
n = n.Next;
}
}
public void Reverse()
{
}
}
thanks in advance