static void Main(string[] args) { var numArray = new int[] { 1, 2, 3, 4, 5 }; var dll = LLHelper.CreateDoublyLinkedList(numArray); Console.WriteLine("Display Forward"); LLHelper.DisplayDoublyForward(dll.Head); Console.WriteLine(); Console.WriteLine("Display Backward"); LLHelper.DisplayDoublyBackward(dll.Tail); Console.WriteLine(); Console.WriteLine("Reversing Doubly LL"); dll = Reverse(dll); Console.WriteLine("Display Forward"); LLHelper.DisplayDoublyForward(dll.Head); Console.WriteLine(); Console.WriteLine("Display Backward"); LLHelper.DisplayDoublyBackward(dll.Tail); Console.WriteLine(); }
static void Main(string[] args) { var numArray = new int[] { 1, 2, 3, 4, 5 }; var dll = LLHelper.CreateDoublyLinkedList(numArray); var termFirst = dll.Head; var termLast = dll.Tail; termFirst.Previous = termLast; termLast.Next = termFirst; Display(dll); Console.WriteLine("Inserting node 100 at first position"); dll = InsertNodeAtFirstPosition(dll); Display(dll); }
static void Main(string[] args) { var numArray = new int[] { 2, 10, 15, 18, 20, 25 }; var dll = LLHelper.CreateDoublyLinkedList(numArray); Console.WriteLine("Display Forward"); LLHelper.DisplayDoublyForward(dll.Head); Console.WriteLine(); Console.WriteLine("Display Backward"); LLHelper.DisplayDoublyBackward(dll.Tail); Console.WriteLine(); Console.WriteLine("Inserting 100 at first position"); dll = InsertDoublyNodeAtFirstPosition(dll); Console.WriteLine("Display Forward"); LLHelper.DisplayDoublyForward(dll.Head); Console.WriteLine(); Console.WriteLine("Display Backward"); LLHelper.DisplayDoublyBackward(dll.Tail); Console.WriteLine(); Console.WriteLine("Insert 500 at third position"); dll = InsertDoublyNodeAtNPosition(dll, 3); Console.WriteLine("Display Forward"); LLHelper.DisplayDoublyForward(dll.Head); Console.WriteLine(); Console.WriteLine("Display Backward"); LLHelper.DisplayDoublyBackward(dll.Tail); Console.WriteLine(); Console.WriteLine("Deleting node at first position"); dll = DeleteDoublyNodeAtFirstPosition(dll); Console.WriteLine("Display Forward"); LLHelper.DisplayDoublyForward(dll.Head); Console.WriteLine(); Console.WriteLine("Display Backward"); LLHelper.DisplayDoublyBackward(dll.Tail); Console.WriteLine(); Console.WriteLine("Deleting node at third position"); dll = DeleteDoublyNodeAtNPosition(dll, 3); Console.WriteLine("Display Forward"); LLHelper.DisplayDoublyForward(dll.Head); Console.WriteLine(); Console.WriteLine("Display Backward"); LLHelper.DisplayDoublyBackward(dll.Tail); Console.WriteLine(); }