Help me describe an algorithm written in C++, in the great and mighty
I searched the web in search of an algorithm for checking a boolean function for monotony, unfortunately, I found it only in C++, but I don't know it myself. I would be very grateful if you describe the teapot in an accessible language.
0
1 answers
If you remove the optimization, you will get the following pseudocode
если длина vec <2 то немонотонна
для i от 0 до длины вектора-1
для j от i до длины вектора
если vec[i]>vec[j] то немонотонна
монотонна
On a, the optimization compares the elements of the vector not in solid pieces, but in chunks from different places and, in principle, should work faster
2
Author: Evgeny Shmidt, 2016-10-26 06:28:30