Hi all,
I think there can be one more solution... where a BFS is folowed by DFS works.

Algo 2:
IsLockable(Node N)
{
     queue Q;
     if(root is not locked)
                Q.insert(root);
     while(!Q.empty()) {
         Node n = Q.removeHead();
         if(n == N)
             return DFS(n);
         for(each child a of N)
            If(a is not locked)
                Q.insert(a);      
     }
     return false;
}

DFS(node)
{
        for (each child a of node)
            if(a is locked || DFS(a) == true)
               return true;
        return false;
}

This will be better than my algo 1, for some trees.

Regards,
Prunthaban
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to