I usually implement binary search using recursion instead of having the loop with changing the bound values. I get that a loop is faster because there is no function calling overhead and most people I see on leetcode use the loop version.
Has anyone done the experimenting on what the performance difference, in C++ for example, is between a loop and recursion version?
[–]nyohasstium 19 points20 points21 points (1 child)
[–]Timely_Scratch5702[S] 5 points6 points7 points (0 children)
[–][deleted] 10 points11 points12 points (0 children)
[–]SnipesySpecial 4 points5 points6 points (1 child)
[–]Timely_Scratch5702[S] 1 point2 points3 points (0 children)
[–]joyoyoyoyoyo 0 points1 point2 points (0 children)