What is the difference between Greedy-Search and Uniform-Cost-Search?

前端 未结 3 721
盖世英雄少女心
盖世英雄少女心 2021-02-01 16:46

When searching in a tree, my understanding of uniform cost search is that for a given node A, having child nodes B,C,D with associated costs of (10, 5, 7), my algorithm will cho

3条回答
  •  佛祖请我去吃肉
    2021-02-01 17:34

    The difference between them is that the Greedy picks the node with the lowest heuristic value while the UCS picks the node with the lowest action cost. Consider the following graph:

    If you run both algorithms, you'll get:

    • UCS

    Picks: S (cost 0), B (cost 1), A (cost 2), D (cost 3), C (cost 5), G (cost 7)

    Answer: S->A->D->G

    • Greedy:

    *supposing it chooses the A instead of B; A and B have the same heuristic value

    Picks: S , A (h = 3), C (h = 1), G (h = 0)

    Answer: S->A->C->G

    So, it's important to differentiate the action cost to get to the node from the heuristic value, which is a piece of information that is added to the node, based on the understanding of the problem definition.

提交回复
热议问题