Assignment 6: implement hierachical clustering