• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 31, 2024 |62.4K Views

Merge two sorted linked lists

  Share  1 Like
Description
Discussion

Write a SortedMerge() function that takes two lists, each of which is sorted in increasing order, and merges the two together into one list which is in increasing order. SortedMerge() should return the new list. The new list should be made by splicing together the nodes of the first two lists.

For example if the first linked list a is 5->10->15 and the other linked list b is 2->3->20, then SortedMerge() should return a pointer to the head node of the merged list 2->3->5->10->15->20.


Merge two sorted linked lists : https://www.geeksforgeeks.org/merge-two-sorted-linked-lists/