In my next code, I am viewing the graph through breadth first search. The code builds a graph as it moves. This is a very large graph with a fan of 12. Because of this, anytime the depth breadth first searchincreases, I want to destroy the layer above it, trying to minimize memory usage. How can I create an algorithm for this?
breadth first search
string Node::bfs(Node * rootNode) { QQueue<Cube *> q; q.enqueue(rootNode); while (!(q.empty())) { Node * currNode = q.dequeue(); currNode->constructChildren(); foreach (Node * child, currNode->getListOfChildren()) { q.enqueue(child); } if (currNode->isGoalNode()) { return currNode->path; } }
, BFS, , . (, K n K ^ n , , n, Theta (K ^ n)).
, . , , "" , DFS, .
"" , - , ( , , ). .
, DFS .
( , ) BFS, O (K ^ n) , n - . DFS O (n).
DFS , DFS, , BFS, "" BFS.
. . , .