greedy algorithm in data structure