Basic Algorithms Implementation