As soon as we started programming, we found to our surprise that it wasn’t as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs. Maurice Wilkes

Union and Intersection of two Linked Lists

Language Java | Level Intermediate | Category Data structure | September 6, 2015 12:01 am

Data structure Description

The singly linked list contains the sequence of nodes which each node contains data and link to the next node. Write a program to print the union and intersection of given two linked lists. The union link combines both linked list and return as singly linked list. The intersection list builds based on common nodes from both linked list.



Find Union and Intersection list 1: [11, 22, 33]
Find Union and Intersection list 2: [22, 33, 44, 55, 66]

Intersection of list1 and list2: [22, 33]
Union of list1 and list2: [33, 66, 22, 55, 11, 44]



No comments available!

Please login to add comments.