Randomized Match Finding
-
06-06-2021 - |
Question
Say I have two files or arrays, type doesn't matter, with a size of 184x184. I try to find out if these items are different with a code like below:
for(i=0; i<N; i++) {
x = r.nextInt(184);
y = r.nextInt(184);
if(item1[x,y] != item2[x,y]) {
break;
}
}
My question is, what should the value of N be? Should I run tests, is there a defacto rate between N and the size?
Solution
As the program gets out of the loop when it finds differents values for the same index:
- It's OK to give N a big number, the loop won't tire the computer as the loop will be broken in at most 10th-20th step.
As differences will be found in very low values of "i":
- There's no need for bigger values of N.
So according to my experimentations, defacto value for N is 20. For similar or background is dominant in the pictures the value can be increased up to 100.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow