scala implementation of basic algorithm data structures