0 votes 0 votes complexity of algorithm to interchange the nth and mth element (node) of singly link list is: a.m+n b.m if m>=n otherwise n c.m if m<=n otherwise n d.m+min(m,n) ans given c???????????how Programming in C data-structures + – akankshadewangan24 asked Dec 2, 2017 akankshadewangan24 833 views answer comment Share Follow See all 6 Comments See all 6 6 Comments reply joshi_nitish commented Dec 2, 2017 reply Follow Share answer should be b), it will take O(max(m,n)) 0 votes 0 votes akankshadewangan24 commented Dec 2, 2017 reply Follow Share How???? 0 votes 0 votes joshi_nitish commented Dec 2, 2017 reply Follow Share to swap node m and n, firstly we have to travel farthest of m and n, which will take O(max(m,n)) , and then swapping can be done in O(1) time. so overall, it will take -> O(max(m,n)) + O(1) = O(max(m,n)) 2 votes 2 votes Ashwin Kulkarni commented Dec 2, 2017 reply Follow Share Yes exactly answer should be B. 0 votes 0 votes Anu007 commented Dec 2, 2017 reply Follow Share if you put O(max(m,n)) then a will also be correct right? let N= n3 and M= n2 Then O(M+N) also saying same b/c of big oh. 0 votes 0 votes joshi_nitish commented Dec 2, 2017 reply Follow Share yes, A) is also right, but B) is more appropriate. 1 votes 1 votes Please log in or register to add a comment.