Exemple #1
0
        public string PrintLinkedList(LinkedListedNodeEx node)
        {
            string result = "";

            while (node != null)
            {
                result += node.Value + ",";
                node    = node.Next;
            }

            result = result.TrimEnd(',');

            return(result);
        }
Exemple #2
0
        public LinkedListedNodeEx ReverseLinkedList(LinkedListedNodeEx head)
        {
            LinkedListedNodeEx currentNode  = head;
            LinkedListedNodeEx nextNode     = null;
            LinkedListedNodeEx previousNode = null;

            while (currentNode != null)
            {
                nextNode         = currentNode.Next;
                currentNode.Next = previousNode;
                previousNode     = currentNode;
                currentNode      = nextNode;
            }

            return(previousNode);
        }