AC-3算法的时间复杂度

问题描述

这是AC-3算法的(伪)代码


function AC-3(csp) returns false if an inconsistency is found and true otherwise
    queue ← a queue of arcs,initially all the arcs in csp
    while queue is not empty do
        (Xi,Xj ) ← Pop(queue)
        if Revise(csp,Xi,Xj ) then
            if size of Di = 0 then return false
            for each Xk in Xi .Neighbors− {Xj } do
                add (Xk,Xi) to queue
    return true

function Revise(csp,Xj ) returns true iff we revise the domain of Xi
    revised ← f alse
    for each x in Di do
        if no value y in Dj allows (x,y) to satisfy the constraint between Xi and Xj then
            delete x from Di
            revised ← true
    return revised

我正在学习 Artificial Intelligence - A Modern Approach (4th edition) 这本书,它是关于该算法的时间复杂度的内容

假设一个 CSP 有 n 个变量,每个变量的域大小最多为 d,并带有二进制约束(弧)。每个弧(Xi,Xj) 只能在队列中插入 d 次,因为 X_i 最多有 d 个要删除的值。检查 弧的一致性可以在 O(d^2) 时间内完成,所以我们得到 O(cd^3) 总最坏情况时间。

  • 我知道每个弧 (Xi,Xj) 只能在队列中插入 d 次(因为 Xi 最多有 d 个要删除的值,最坏的情况下可以一一删除)。
  • 我不明白如何在 O(d^2) 中检查单个弧的一致性。我认为它可能是 O(cd),因为在最坏的情况下,它可以从所有变量的域中一一删除所有值。
  • 我不明白它给出的最坏情况总时间,即 O(cd^3)在这种情况下,在我看来,它可以改为 O(cd^2)

你会如何计算这个算法的时间复杂度?我哪里错了?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)