public static void Start(string list, int rotationPoint) { var head = new DoubleNode(list); Console.Write($"Original List: "); head.Print(); var rotatedList = Rotate(head, rotationPoint); Console.Write($"Rotated List: "); rotatedList.Print(); }
private void CreateListFromString(string numbers) { var numbersArray = numbers.Split(' ').Select(numberStr => int.Parse(numberStr)).ToList(); Data = numbersArray[0]; DoubleNode currentNode = this; for (int iterator = 1; iterator < numbersArray.Count; iterator++) { var node = new DoubleNode(numbersArray[iterator]); currentNode.Next = node; node.Prev = currentNode; currentNode = currentNode.Next; } }
public DoubleNode(int data) { Data = data; Prev = null; Next = null; }