Guest User

Untitled

a guest
Jun 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. def merge(left,right):
  2.   S=DirectedList()
  3.   S_pos=S.first()
  4.   while not left.isempty() and not right.isempty():
  5.     if left.inspect(left.first()) <= right.inspect(right.first()):
  6.       S.insert(S_pos,left.inspect(left.first()))   #ska lägga in elementet på sista plats
  7.       S_pos=S.next(S_pos)
  8.       left.remove(left.first())
  9.                                              
  10.     else:
  11.       S.insert(S_pos,right.inspect(right.first()))  #samma
  12.       S_pos=S.next(S_pos)
  13.       right.remove(right.first())
  14.        
  15.   while not left.isempty():
  16.     S.insert(S_pos,left.inspect(left.first()))    #samma
  17.     S_pos=S.next(S_pos)
  18.     left.remove(left.first())
  19.      
  20.   while not right.isempty():
  21.     S.insert(S_pos,right.inspect(right.first()))  #samma
  22.     S_pos=S.next(S_pos)
  23.     right.remove(right.first())
  24.    
  25.   return S
Add Comment
Please, Sign In to add comment