mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-28 16:43:38 +00:00
updated merge function
This commit is contained in:
parent
d96cc64ce7
commit
fdbea27d41
@ -331,12 +331,15 @@ class SortedLinkedList:
|
|||||||
"""
|
"""
|
||||||
if other_list.head is None:
|
if other_list.head is None:
|
||||||
return
|
return
|
||||||
if self.head is None:
|
elif self.head is None:
|
||||||
self.head = other_list.head
|
self.head = other_list.head
|
||||||
self.tail = other_list.tail
|
self.tail = other_list.tail
|
||||||
return
|
return
|
||||||
self.tail.next_node = other_list.head
|
else:
|
||||||
self.tail = other_list.tail
|
temp=otherother_list.head
|
||||||
|
while temp:
|
||||||
|
self.insert(temp.data)
|
||||||
|
temp=temp.next_node
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user