Algorithm needed
-
I have two sets: A{1,2,3,4,5} and B{1,3,5} I need to create set C{2,4}. Is there an optimal algorithm designed for this task? Right now I’m simply going to stick A into an array and sort it. Then I’ll iterate through each element in B and do a binary search for it in A. If not found then put it into C. Is there a better way?
-
I have two sets: A{1,2,3,4,5} and B{1,3,5} I need to create set C{2,4}. Is there an optimal algorithm designed for this task? Right now I’m simply going to stick A into an array and sort it. Then I’ll iterate through each element in B and do a binary search for it in A. If not found then put it into C. Is there a better way?
Try the following site http://home.att.net/~srschmitt/Sets\_class.html :)
-
I have two sets: A{1,2,3,4,5} and B{1,3,5} I need to create set C{2,4}. Is there an optimal algorithm designed for this task? Right now I’m simply going to stick A into an array and sort it. Then I’ll iterate through each element in B and do a binary search for it in A. If not found then put it into C. Is there a better way?
-
I have two sets: A{1,2,3,4,5} and B{1,3,5} I need to create set C{2,4}. Is there an optimal algorithm designed for this task? Right now I’m simply going to stick A into an array and sort it. Then I’ll iterate through each element in B and do a binary search for it in A. If not found then put it into C. Is there a better way?