// WARNING: THIS CODE HAS NOT BEEN TESTED. // IT WILL TAKE 1-2 MONTHS TO PERFECT THE CODE. // IF YOU FACE ANY ERRORS, UNEXPECTED BEHAVIOUR OR HAVE ANY SUGGESTIONS, // LET US KNOW BY CREATING AN ISSUE ON OUR KSKA GIT REPOSITORY. /* 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 connects all your offices with a minimum total cost. Solve the problem by suggesting appropriate data structures. Code from Data Structures and Algorithms (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/DataStructuresAndAlgorithms/ */ // BEGINNING OF CODE #include using namespace std; class Office { int n; int a[10][10]; string office[10]; public: void input(); void display(); void Prims(); }; void Office::input() { cout<<"\nEnter no. of offices: "; cin>>n; cout<<"\nEnter the names of offices: "; for(int i=0 ; i> office[i]; cout<<"\nEnter the cost to connect the offices: "; for(int i=0 ; i> a[i][j]; a[j][i] = a[i][j]; } } void Office::display() { for(int i=0 ; i "; while(1) { minCost = 10000; for(int i=0 ; i "; cost = cost + minCost; count++; if(count==n) break; } cout<<"\nMinimum cost: "<> choice; switch(choice) { case 1: o1.input(); break; case 2: o1.display(); break; case 3: o1.Prims(); break; case 4: return 0; default: cout<<"\nInvalid choice.Try again!"; } if(choice != 5) goto MENU; return 0; } // END OF CODE // EXPERIMENTAL CODE