Example #1
0
        public int FindMergeNode_ForTwoLists_ReturnsDataFromFirstSharedNode(
            int[] firstIndices,
            int[] secondIndices,
            int[] sharedIndices
            )
        {
            TestSinglyLinkedList onlyFirst  = SinglyLinkedListHelper.CreateLinkedList(firstIndices);
            TestSinglyLinkedList onlySecond = SinglyLinkedListHelper.CreateLinkedList(secondIndices);
            TestSinglyLinkedList onlyShared = SinglyLinkedListHelper.CreateLinkedList(sharedIndices);

            SinglyLinkedListNode firstHead  = ConcatLists(onlyFirst, onlyShared);
            SinglyLinkedListNode secondHead = ConcatLists(onlySecond, onlyShared);

            return(MergePoint.FindMergeNode(firstHead, secondHead));
        }
        public bool CycleDetection_ForGivenListOfNodeLinks_ReturnsTrueIfHasCycle(int[] indices)
        {
            SinglyLinkedListNode head = SinglyLinkedListHelper.CreateLinkedList(indices).Head;

            return(CycleDetection.HasCycle(head));
        }