Bitap algorithm