Home > Blockchain >  pseudocode notation / find a pair such that when you subtract one from the other it should equal to
pseudocode notation / find a pair such that when you subtract one from the other it should equal to

Time:01-22

it has been a while I worked anything in pseudo code.

    Let a ∈ A
    A := A \ { a }

Can you tell me, specifically what this part is -> A := A \ { a } a should be the set members, so a pair?

CodePudding user response:

Initialize all items of the array X by -1

For at most m steps:

  1. Pick a number from the set A and keep it in the variable a
  2. Remove a from the set A
  3. Calculate r = a mod n (remainder of a / n)
  4. If X[r] = -1 (there is no a such that r = a mod n before), then set X[r] = a, Else, (there was a such that r = a mod n before) so return the pair (X[r], a) which both have the same remainder respect with n.
  •  Tags:  
  • Related