Skip to main content

Posts

Find Minimum Spanning Tree using Prim's Algorithm of Graph | Representation of Graph using Adjacency List

  Problem Statement:- You have a business with several offices; you want to lease phone lines to connect them up with each other, and the phone company charges different amounts of money to connect different pairs of cities. You want a set of lines that connect all your offices with a minimum total cost. Solve the problem by suggesting appropriate data structures. Note :- Scroll horizontally to see the full line of code. #include < iostream > using namespace std ; class flagarray {     string data ;     int flag ; public :     flagarray ()     {         this -> data = "" ;         this -> flag = 0 ;     }     flagarray ( string data , int flag )     {         this -> data = data ;         this -> flag = flag ;     }     friend class node ;     friend class graph ; }; cla...

Depth-First-Search and Breadth-First-Search Traversal of Graph | DFS and BFS of Graph | Representation of Graph using Adjacency List using Linked List

  Problem Statement: - Represent a given graph using an adjacency list to perform DFS and BFS. Use the map of the area around the college as the graph. Identify the prominent landmarks as nodes and perform DFS and BFS on that. Note :- Scroll horizontally to see the full line of code. #include < iostream > #include < string.h > using namespace std ; class flagarray {     string data ;     int flag ; public :     flagarray ()     {         this -> data = "" ;         this -> flag = 0 ;     }     flagarray ( string data , int flag )     {         this -> data = data ;         this -> flag = flag ;     }     friend class stack ;     friend class queue ;     friend class node ;     friend class graph ; }; class stack ; class queue ; class ...