base case in greedy and astar changed