- Algorithms-Graph Traversals, BFS, DFS, Graph

Find all the Mother Vertices of a graph

  #include using namespace std;  void dfs_helper(int u,                vector& adj,                bool visited[]){    if (visited[u])        return;      visited[u] = true;      for (auto v : adj[u]) {        if (!visited[v])            dfs_helper(v, adj, visited);    }}  void getTransposeGraph(    vector&…

Read More

- Algorithms, BFS, Binary Tree, cpp-map, cpp-queue, cpp-random, Queue, Randomized, Tree

Test Case Generation | Set 6 (Random Unweighted Binary Tree)

  #include using namespace std;    vector generateBinaryTree(int n){                        vector options = { 0, 1, 2 };                        map mp;                queue q;            q.push(1);            vector v;                int count = 1;                mp[1] =…

Read More