using System.Collections.Generic;
using System.Threading.Tasks;
public static void Main()
Console.WriteLine("Find Kth element from the last element in the list. Enter the value of K:");
k = Convert.ToInt32(Console.ReadLine());
list.FindKthElement(list.Head, k);
Console.WriteLine("---------------------");
private Node next = null;
internal void ShowNodes()
Console.WriteLine("No more nodes to display.");
Console.WriteLine("Node : " + current.Data);
internal void ShowLength()
string numString = "numbers";
Console.WriteLine(String.Format("List has [{0}] {1}.", _length.ToString(), numString));
Console.WriteLine(String.Format("Add node [{0}].", d.ToString()));
Node newNode = new Node(d);
while (current.Next != null)
internal void FindKthElement(Node head, int k)
FindKthElement(head.Next, k);
Console.WriteLine(String.Format("Element at index [{0}] from the last element in the list is [{1}].", k.ToString(), head.Data.ToString()));