|
-
Sep 23rd, 2002, 11:55 PM
#1
Thread Starter
Fanatic Member
computing unions of sets
I'm having a hard time designing an algorithm to compute a union of a bunch of sets on closed intervals.
For example if you have sets like these:
[5,10] [2.2,3] [1,2] [3.1,7] [1.5,2.5], the algorithm should return [1,3] [3.1,10].
Also how would you merge x number of linked lists (already sorted) into one (also sorted) linked list.
In both cases I'm looking for as efficient design as possible.
Thanks
Q
-
Sep 24th, 2002, 07:18 AM
#2
Thread Starter
Fanatic Member
-
Sep 24th, 2002, 07:33 AM
#3
PowerPoster
Your question isa total mess (at least it looks this way to me):
you say you need "...to compute a union of a bunch of sets ..." but your sample shows me that you need to select HIGHER bumbers.
Also, what do you mean by saying: "... how would you merge x number of linked lists ..."? Be more specific, please.
-
Sep 24th, 2002, 07:38 AM
#4
So Unbanned
Better switch to decaf.
-
Sep 24th, 2002, 08:16 AM
#5
Thread Starter
Fanatic Member
merge two linked lists (or any number for that matter):
lets say that you have two linked lists (I assume that you know about that data type).
List 1: (1, 3, 5, 7, 9, 11, 13)
List 2: (2, 4, 6, 8, 10, 12, 14)
I need to be able to come up with a new list that looks like this:
(1,2,3,4,5,6,7,8,9,10,11,12,13,14).
I know that I could just do it by comparing the numbers one by one, but I need to come up with something way more efficient.
Second thing: that's exactly what the union of the bunch of sets would look like (UNION of A B C: elements that are in A + Elements that are in B + elements that are in C).
Thanks
Q
-
Sep 24th, 2002, 08:19 AM
#6
So Unbanned
Loop through the set, then instr to check a string, then add numbers like num & ","
if you want it in an array you can then split it.
-
Sep 24th, 2002, 08:27 AM
#7
PowerPoster
You will have to first merge two lists (arrays) into ONE and then SORT it. For more help on sorting check out this link:
http://www.vb-helper.com/tut1.htm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|