Graph
图遍历算法
BFS
public void bfs(Node root){
if(root == null){
return;
}
Queue<Node> q = new LinkedList<>();
q.offer(root);
while(!q.empty()){
int size = q.size();
for(int i = 0; i < size; i++){
Node n = q.poll();
if(n.left != null){
q.offer(n.left);
}
if(n.right != null){
q.offer(n.right);
}
}
}
}
Time O(n)
Space O(n)Determine whether a binary tree is a complete binary tree
Dijkstra Algorithm
DFS
Find All Subsets of a Set {a, b, c}
Find All Permutation
Last updated