Thursday, 15 April 2010

algorithm - merge sorted lists -



algorithm - merge sorted lists -

i trying come split , conquer algorithm merging j sorted lists n number of elements i'm stuck; don't know how split problem smaller sub-problems. want more efficient merging algorithm goes this:

merge first 2 lists; merge resulting list 3rd list; merge resulting list 4th list, etc. takes o(j * jn).

u can in o(j*log(j)n) time

while(n!=1) i=0 n/2 merge list(i) list list(n) n = n/2

that way u merge whole grouping pairs, pairs of pairs , on

algorithm merge divide-and-conquer

No comments:

Post a Comment