public void tDeleteMiddleNode() { ListNode nodeE = new ListNode('E'); ListNode nodeD = new ListNode('D', nodeE); ListNode nodeC = new ListNode('C', nodeD); ListNode nodeB = new ListNode('B', nodeC); ListNode nodeA = new ListNode('A', nodeB); ListNode node = nodeA; char result; bool exists = false; DeleteMiddleNode.DeleteNode(nodeC); while (!ReferenceEquals(null, node)) { result = node.data; if (result == 'C') { exists = true; break; } node = node.next; } Assert.IsFalse(exists); }
public void DeleteMiddleNodeTest(string source, int k, string expected) { var head = Node <int> .FromString(source); var nodeToDelete = head?.KthNode(k); DeleteMiddleNode.Execute(nodeToDelete); Assert.Equal(expected, head?.ToLinkedListString() ?? ""); }
public void DeleteMiddleNodeTest() { var input = Node.BuildNodeListOne(); DeleteMiddleNode.Run(input.Next.Next); Assert.Equal("534561", TestHelpers.ToString(input)); DeleteMiddleNode.Run(input.Next.Next.Next); Assert.Equal("53461", TestHelpers.ToString(input)); }
public void DeleteMiddleNodetest() { var nodeToBeDeleted = new Node(15); var head = new Node(1).AppendToTail(2).AppendToTail(3).AppendToTail(nodeToBeDeleted).AppendToTail(4).AppendToTail(5).AppendToTail(6) .AppendToTail(7).AppendToTail(8); DeleteMiddleNode.DeleteMiddleNodeAlgo(nodeToBeDeleted); var node = head; var result = ""; var expected = "1-2-3-4-5-6-7-8"; while (node != null) { result += node.Data; result += "-"; node = node.Next; } result.Substring(0, result.Length - 1).Should().Be(expected); }
static void Main(string[] args) { var condition = true; //just keeping the current solving problem in if condition; nothing else if (condition) { KStacks.MainMethod(); } else { #region LinkedLists LinkIntersection.MainMethod(); SumList.MainMethod(); RemoveDups <int> .MainMethod(); ReturnKthToLast.MainMethod(1); DeleteMiddleNode.MainMethod(); LoopDetection.MainMethod(); #endregion #region Array and Strings StringRotation.IsStringRotation("waterbottle", "erbottlewat"); ZeroMatrixImplementation(); RotateMatrixImplementation(4); StringCompression.CompressedString("aabcccccaaa"); OneAway.IsStringOneAway("pale", "paled"); PalindromePermutation.IsPalindromePermutation("Mr. owl ate my Metal worm"); URLify.URLifyString("Spaces in this string will be replaced by percent20"); IsStringPermutation.VerifyStringPermutation("abdcdefgh", "aefgb2cdh"); UniqueString.VerifyUniqueStringAsciiSet("!@#$%$^&*()EFgh"); HashTableImplentation(); SwapWithoutTemp.SwapWithoutTempVar(12, 24); #endregion } }
public void DeleteMiddleNodeTest(Node <int> input, Node <int> expected) { Node <int> newList = DeleteMiddleNode.Delete(input); Assert.Equal(expected, newList); }
public void Setup() { deleteMiddleNode = new DeleteMiddleNode(); }