enter image description here Rummaged in the network in search of the algorithm for checking the Boolean function for monotony, unfortunately, I found only in C ++, but I don’t own it. I would be very grateful if you describe the teapot in an accessible language.

  • it is better to attach the picture normally, and not after ten clicks on the site, on which there is also video advertising, making its way through the filters. But there is a description in Russian in the text. > The function is monotonous when the condition f (xxx0xxx) <= f (xxx1xxx) is satisfied> That is, if for each vector X we get a set of vectors {X '} such that some of the zeros from X are replaced with ones, and we check that conditions f (X) <= f (X ') ... - KoVadim
  • Sorry for the curve link, hurried. So I understand the principle of determining monotonous functions, but I need exactly the algorithm described by the code ( - nONo
  • The code is written quite simply. There is nothing that goes beyond the formula described above. It's just that the code is trying to optimize this thing prematurely. Or do you think if you simply translate into Russian, (if - if that and the like), then it will become easier? - KoVadim
  • It's just that my C ++ level is below sea level, and the algorithm is needed urgently. - nONo
  • If you can describe the algorithm in the form of a pseudo-code, I will be immensely grateful) - nONo

1 answer 1

If you remove the optimization will get the next pseudocode

если длина vec <2 то немонотонна для i от 0 до длины вектора-1 для j от i до длины вектора если vec[i]>vec[j] то немонотонна монотонна 

on, and the optimization compares the elements of the vector not in a solid, but in chunks from different places and, in principle, should work faster