Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among union, intersection, membership, cardinality will be the slowest? (GATE CS 2004)

**(A)** union only

**(B)** intersection, membership

**(C)** membership, cardinality

**(D)** union, intersection

**Answer:** **(D)** **Explanation:** For getting intersection of L1 and L2, search for each element of L1 in L2 and print the elements we find in L2.

There can be many ways for getting union of L1 and L2. One of them is as follows

a) Print all the nodes of L1 and print only those which are not present in L2.

b) Print nodes of L2.

All of these methods will require more operations than intersection as we have to process intersection node plus other nodes.

Quiz of this Question

## Recommended Posts:

- Data Structures | Linked List | Question 6
- Data Structures | Linked List | Question 15
- Data Structures | Linked List | Question 16
- Data Structures | Linked List | Question 3
- Data Structures | Linked List | Question 12
- Data Structures | Linked List | Question 11
- Data Structures | Linked List | Question 5
- Data Structures | Linked List | Question 17
- Data Structures | Linked List | Question 1
- Data Structures | Linked List | Question 9
- Data Structures | Linked List | Question 4
- Data Structures | Linked List | Question 2
- Data Structures | Linked List | Question 14
- Data Structures | Linked List | Question 13
- Data Structures | Linked List | Question 7
- Data Structures | Linked List | Question 8
- Introduction to Data Structures | 10 most commonly used Data Structures
- Data Structures | Graph | Question 4
- Data Structures | Queue | Question 11
- Data Structures | Heap | Question 6