Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node(object):
- def __init__(self, data=None):
- self.data = data
- self.next = None
- def sorted_merge(first, second):
- fake = Node(-1)
- current = fake
- if first is None and second is None:
- return None
- if first is None:
- return second
- if second is None:
- return first
- while(first.next and second.next):
- if(first.data >= second.data):
- current.next = second
- current = second
- second = second.next
- else:
- current.next = first
- current = first
- first = first.next
- if first.next is not None:
- current.next = first
- if second.next is not None:
- current.next = second
- print(current)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement