How to Insert a node into alternating linked list after the current node?
Clash Royale CLAN TAG #URR8PPP How to Insert a node into alternating linked list after the current node? I am writing a linked list function that alternates the nodes odd/even.For example if the input was 6->7->5->3->6->2->9->1 it would output 6->7->6->5->2->3->5->9->1 . The issue I am having is when I run my code I get 6->6->7->2->5->3->5->9->1 .I know the issue stems from the node being inserted before the 7. When it should be inserted after the 7. However, I can't seem to figure out how this is done. How would I go about inserting it after the 7? 6->7->5->3->6->2->9->1 6->7->6->5->2->3->5->9->1 6->6->7->2->5->3->5->9->1 Here is a copy of my function. I am pretty for sure the issue is in the final if loop. void InterleaveOddsAndEvensInOrigOrder(Node*& headPtr) { if(headPtr ==0 || headPtr->link == 0) { cout << ...