recategorized by
678 views
3 votes
3 votes
Two linked lists having n and m elements are stored in sorted order. What is the worst case complexity of program to print common elements of two lists ?

$\begin{align*} &A. \ \ O(n) \\ &B. \ \ \text{max}(m,n) \\ &C. \ \ \text{min}(m,n) \\ &D. \ \ m+n \end{align*}$
recategorized by

2 Answers

Best answer
7 votes
7 votes
O(m+n) similar to combine step of merge sort.
selected by

Related questions

1 votes
1 votes
1 answer
1
5 votes
5 votes
1 answer
3
hacker16 asked Nov 14, 2017
3,428 views
What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?O(n)O(1)θ(n2)θ...