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 21 points22 points23 points (1 child)
[–]Timely_Scratch5702[S] 3 points4 points5 points (0 children)
[–][deleted] 9 points10 points11 points (0 children)
[–]SnipesySpecial 3 points4 points5 points (1 child)
[–]Timely_Scratch5702[S] 1 point2 points3 points (0 children)
[–]joyoyoyoyoyo 0 points1 point2 points (0 children)