I am not sure if it happened to anyone else but the code didn't go as expected on my IDE, the third test case by which I mean (the middle pivot) has a wrong answer for the number of comparisons.
the issue simply is that the function that maps the flag into an index is giving me a floating index which causes a run time error, so I had to convert the answer to an integer value. (denoted by yellow)
the second issue is that the condition in the function that returns the pivot (ChoosePivot) value needs to convert the division result (n/2) to an integer so that the condition goes the right way. (denoted by red)
after I edited it, I got the correct answer.
BTW, I am not a python coder but I am happy to help.
I am not sure if it happened to anyone else but the code didn't go as expected on my IDE, the third test case by which I mean (the middle pivot) has a wrong answer for the number of comparisons. the issue simply is that the function that maps the flag into an index is giving me a floating index which causes a run time error, so I had to convert the answer to an integer value. (denoted by yellow)
the second issue is that the condition in the function that returns the pivot (ChoosePivot) value needs to convert the division result (n/2) to an integer so that the condition goes the right way. (denoted by red)
after I edited it, I got the correct answer. BTW, I am not a python coder but I am happy to help.