Added the bottom up algo