Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Compare data in two groups

Reply
Thread Tools

Compare data in two groups

 
 
Davy
Guest
Posts: n/a
 
      07-22-2005
Hello all,

I have two groups of digit data. The data in it may be repeated.
Some thing like {5 59 74 17 5 1} and {3 8 25 4}. And real group is
larger. Each may own thousands of data.
I want to write a program to compare the two groups.

//------program--------
IF (one data in Group 1 == one data in Group 2)
EXIT the program.

Is there any quick compare algorithm?

Best regards,
Davy

 
Reply With Quote
 
 
 
 
David Resnick
Guest
Posts: n/a
 
      07-22-2005
Davy wrote:
> Hello all,
>
> I have two groups of digit data. The data in it may be repeated.
> Some thing like {5 59 74 17 5 1} and {3 8 25 4}. And real group is
> larger. Each may own thousands of data.
> I want to write a program to compare the two groups.
>
> //------program--------
> IF (one data in Group 1 == one data in Group 2)
> EXIT the program.
>
> Is there any quick compare algorithm?
>
> Best regards,
> Davy


Nothing about this is specific to C, and comp.programming is likely
a better place for general algorithm questions.

Some random ideas to ponder (no promises of efficiency).

1) Sort one data set and then use binary search for each member of the
other set.

2) Hash one data set (make a hashtable) and look up each member of
the other set

3) Sort both sets, iterate through both comparing as you go (not hard)

4) If you are not stuck on using C, you could use C++ sets and get
the intersection (if you want this, go to comp.lang.c++ to discuss)

-David

 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      07-22-2005
"Davy" <> writes:
> I have two groups of digit data. The data in it may be repeated.
> Some thing like {5 59 74 17 5 1} and {3 8 25 4}. And real group is
> larger. Each may own thousands of data.
> I want to write a program to compare the two groups.


When you re-post this question to a more appropriate newsgroup, like
comp.programming, you might want to define the problem better. I can
guess what you mean by "compare", but I can't be sure.

Rigorously and unambiguously defining the problem may get you much of
the way to a solution.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Emmanuel Delahaye
Guest
Posts: n/a
 
      07-23-2005
Davy wrote on 22/07/05 :
> I have two groups of digit data. The data in it may be repeated.
> Some thing like {5 59 74 17 5 1} and {3 8 25 4}. And real group is
> larger. Each may own thousands of data.
> I want to write a program to compare the two groups.
>
> //------program--------
> IF (one data in Group 1 == one data in Group 2)
> EXIT the program.
>
> Is there any quick compare algorithm?


Yes, based on:

qsort()
bsearch()
loops...

Be smart.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

I once asked an expert COBOL programmer, how to
declare local variables in COBOL, the reply was:
"what is a local variable?"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
want to compare data in two files. viupljindal@gmail.com Ruby 4 08-22-2008 07:17 AM
Two VPN groups on PIX 506 - Two Radius Servers on LAN Pichi_b Cisco 1 03-30-2007 10:30 AM
How to compare two SOAP Envelope or two Document or two XML files GenxLogic Java 3 12-06-2006 08:41 PM
Compare data in two groups Davy C++ 1 07-22-2005 01:32 PM
Windows groups, VPN groups, and SecureACS John Sasso Cisco 0 10-02-2004 03:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57