Program to delete a new node from the middle of the singly linked listExplanationIn this program, we will create a singly linked list and delete a node from the middle of the list. To accomplish this task, we will calculate the size of the list and then divide it by 2 to get the midpoint of the list. Node temp will point to head node. We will iterate through the list till mid?point is reached. Now, the temp will point to middle node and node current will point to node previous to temp. We delete the middle node such that current's next node will point to temp's next node. Consider the above example, midpoint of the above list is 2. Iterate temp from head to midpoint. Now, temp is pointing to mid node which needs to be deleted. In this case, Node is the middle node which needs to be deleted. The node can be deleted by making node 2's next (current) to point to node 3 (temp's next node). Set temp to null. Algorithm
SolutionPythonOutput: Original List: 1 2 3 4 Updated List: 1 3 4 Updated List: 1 4 Updated List: 4 Updated List: List is empty COutput: Original List: 1 2 3 4 Updated List: 1 3 4 Updated List: 1 4 Updated List: 4 Updated List: List is empty JAVAOutput: Original List: 1 2 3 4 Updated List: 1 3 4 Updated List: 1 4 Updated List: 4 Updated List: List is empty C#Output: Original List: 1 2 3 4 Updated List: 1 3 4 Updated List: 1 4 Updated List: 4 Updated List: List is empty PHPOutput: Original List: 1 2 3 4 Updated List: 1 3 4 Updated List: 1 4 Updated List: 4 Updated List: List is empty
Next Topic#

Ansible
Mockito
Talend
Azure
SharePoint
Powershell
Kali Linux
OpenCV
Kafka
Pandas
Joomla
Reinforcement