Merging two sets in c++

Revision en4, by kissu_pari_na, 2018-01-30 03:27:26

Is there any solution that will merge two sets in n=( size_of_se1 + size_of_set2 ) times in c++? If I iterate through both the sets and take the smaller value and insert it in another set, this way I can merge two sets but it will take close to n*logn time as set insert operation takes logn time. Also I can let the set1 unchanged and insert all the elements of set2 in set1 or vice versa but it will also take size_of_set2*log(size_of_set1) or size_of_set1*log(size_of_set2) time. I am searching for a solution if it is actually possible to merge two sets in linear time. I googled it and spend some time to find out any solution regarding to it but failed :( Can anyone help me with your valuable opinion? thanks in advance :)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English kissu_pari_na 2018-01-30 03:27:26 1 Tiny change: 'in advanced :)' -> 'in advance :)'
en3 English kissu_pari_na 2018-01-30 03:25:49 14 Tiny change: 't2 ) times? If I ite' -> 't2 ) times in c++? If I ite'
en2 English kissu_pari_na 2018-01-30 03:21:48 101
en1 English kissu_pari_na 2018-01-30 03:02:55 840 Initial revision (published)