Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pairwise swap in data structure in python

# Recursive function to pairwise swap elements of a linked list
def pairWiseSwap(head):
 
    # There must be at-least two nodes in the list
    if (head != None and head.next != None):
  
        # Swap the node's data with data of next node
        swap(head.data, head.next.data);
  
        # Call pairWiseSwap() for rest of the list
        pairWiseSwap(head.next.next);
 
# This code is contributed by _saurabh_jaiswal
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #pairwise #swap #data #structure #python
ADD COMMENT
Topic
Name
7+1 =