#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# comparing large amounts of data

Posts: 53Member
Hi everybody,

could anybody help me with the following task:

i have an array of data: adata[n].
now (at least) k elements of this array are equal, but i don't know which. comparing two elements is very time expensive, so i want to do this task with comparing as little elements as possible.
how could i get the indices of the equal elements?

k is greater than n/2, so that there can only be one solution.
also k elements of the elements should be equal, but this is not sure.
it should also be possible to determine fast if there are (at least) k equal elements in the array.

· ·

• Posts: 89Member
You should keep the data in two hash-tables instead and go from there. This would give constant time-complexity of your operations.

: Hi everybody,
:
: could anybody help me with the following task:
:
: i have an array of data: adata[n].
: now (at least) k elements of this array are equal, but i don't know which. comparing two elements is very time expensive, so i want to do this task with comparing as little elements as possible.
: how could i get the indices of the equal elements?
:
: k is greater than n/2, so that there can only be one solution.
: also k elements of the elements should be equal, but this is not sure.
: it should also be possible to determine fast if there are (at least) k equal elements in the array.
:
:

· ·
• Posts: 53Member
The actual problem: I'm reading sectors from a compact disc which is probably dirty and scratched. I read them n times, and then want to find out which one is the sector actually on the cd. now i say: at least k elements have to be equal, then this must be the sector actually found on the cd.
but i have already found a solution with the help of my math teacher.

: You should keep the data in two hash-tables instead and go from there. This would give constant time-complexity of your operations.
:
:
: : Hi everybody,
: :
: : could anybody help me with the following task:
: :
: : i have an array of data: adata[n].
: : now (at least) k elements of this array are equal, but i don't know which. comparing two elements is very time expensive, so i want to do this task with comparing as little elements as possible.
: : how could i get the indices of the equal elements?
: :
: : k is greater than n/2, so that there can only be one solution.
: : also k elements of the elements should be equal, but this is not sure.
: : it should also be possible to determine fast if there are (at least) k equal elements in the array.
: :
: : Thanks for your help.
: :
:
:

· ·
• Posts: 10Member
You can use an ASM dll wich contains
repnz scasb
. Asm is Quick to run, so you can compare large amount of ram data easly.
Download nasm at cryogen.com . Take in mind that nasm do NOT compile as the other compilator.
· ·