r/algorithms • u/ColdRainFD • 2d ago
Help Doubt in proof writing
For this problem -
https://cses.fi/ckvo8q5wh/task/3419
How can I go about proving that the solution is true for all N?
The solution by the way is simple - we just have to XOR the row and column indice values for each Aij entry. So, Aij = i ^ j. How can I prove this mathematically?
1
u/jeffgerickson 1d ago
How can I prove this mathematically?
In the context of algorithm design, the answer to that question is almost always “induction”.
1
u/icantseekgod 1d ago
if i did this question i would do an induction proof along the lines of:
for all n belonging to naturals, p(n) -> p(n+1)
where p(n) is " for a matrix of nxn for all i,j belonging to {1, .. , n}, for all c belonging to {1,.., j-1}, matrix[i][c] neqv matrix[i][j] and for all r belonging to {1,..,i-1}, matrix[r][j] neqv matrix[i][j], and <insert part about matrix\[i\]\[j\] being the smallest non neg int that hasnt shown up to the left of row or above col> "
3
u/MagicalPizza21 2d ago
What have you tried? Do you have any ideas? What algorithm-proving techniques have you learned?