As form the lectures i know that bool return true or false based on condition mention
if the Condition is True then it will going to perform the swap operation if that i wrote return a < b
in my example my a and b is 50 30 , 50 < 30 which is false so in that case swappping is not going to perform . but it happened ? I am going to swap if the first element is greater than second
GCD problem to fiind out numbers
@Vikaspal I did not get what you are trying to say. But I think you have confusion regarding how the comp function works inside the sort.
See the the two arguments in the function represent their relative positions , that is at what condition a will come before b.
cmp(int a, int b)
{
return a>b;
}
Now this comp function modifies the array in such a way that element occurring before will be bigger. (a is first argument and func return true when it is larger so array should be descending)
If this resolves your doubt mark it as resolved.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.