Tag: algorithm
-
Theoretically can the Ackermann function be optimized?
9 I am wondering if there can be a version of Ackermann function with better time complexity than the standard variation. This is not a homework and I am just curious. I know the Ackermann function doesn’t have any practical use besides as a performance benchmark, because of the deep recursion. I know the numbers…
-
Faster algorithm for max(ctz(x), ctz(y))?
13 For min(ctz(x), ctz(y)), we can use ctz(x | y) to gain better performance. But what about max(ctz(x), ctz(y))? ctz represents "count trailing zeros". C++ Version (Compiler Explorer) #include <algorithm> #include <bit> #include <cstdint> int32_t test2(uint64_t x, uint64_t y) { return std::max(std::countr_zero(x), std::countr_zero(y)); } Rust Version (Compiler Explorer) pub fn test2(x: u64, y: u64) ->…