Efficient and scalable exact inference algorithms for Bayesian networks