pseudocode for kmeans and HAC