Depth-first-search

Level: Beginner

1. Implement the basic Depth First Search (DFS) for a graph.
2. Write a function to perform DFS on a tree.
3. Implement a function to find the number of connected components in an undirected graph using DFS.
4. Write a function to detect a cycle in an undirected graph using DFS.
5. Implement a function to find the path from the root to a given node in a tree using DFS.
6. Write a function to find all leaf nodes in a binary tree using DFS.
7. Implement a function to find the depth of a binary tree using DFS.
8. Write a function to print all nodes at a given depth in a binary tree using DFS.
9. Implement a function to perform in-order traversal of a binary tree using DFS.
10. Write a function to perform pre-order traversal of a binary tree using DFS.
11. Implement a function to perform post-order traversal of a binary tree using DFS.
12. Write a function to find the sum of all nodes in a binary tree using DFS.
13. Implement a function to find the maximum value in a binary tree using DFS.
14. Write a function to find the minimum value in a binary tree using DFS.
15. Implement a function to count the number of nodes in a binary tree using DFS.
16. Write a function to find the height of a binary tree using DFS.
17. Implement a function to check if two binary trees are identical using DFS.
18. Write a function to find the diameter of a binary tree using DFS.
19. Implement a function to find the lowest common ancestor (LCA) of two nodes in a binary tree using DFS.
20. Write a function to find the longest path in a binary tree using DFS.
21. Implement a function to find all paths from the root to leaf nodes in a binary tree using DFS.
22. Write a function to find the sum of all left leaves in a binary tree using DFS.
23. Implement a function to find the sum of all right leaves in a binary tree using DFS.
24. Write a function to convert a binary tree to a doubly linked list using DFS.
25. Implement a function to clone a binary tree using DFS.
26. Write a function to check if a binary tree is balanced using DFS.
27. Implement a function to find all ancestors of a given node in a binary tree using DFS.
28. Write a function to find all descendants of a given node in a binary tree using DFS.
29. Implement a function to perform DFS on a graph represented as an adjacency matrix.
30. Write a function to perform DFS on a graph represented as an adjacency list.

Intermediate Level: View

Advanced Level: View