Professional Documents
Culture Documents
Problem Solving Approach Using Data Structures in Algorithms
Problem Solving Approach Using Data Structures in Algorithms
Scenario There is a business company with several offices. It wants 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. The company want a set of lines that connects all the offices with a minimum total cost. Suggest a suitable approach to do so?
AA 13 7 #
BB 1 D
C "
3 F
Approach 1
$ets us %ra& all the possible combinations to connect cities &ith each other an% 'in% the combination &ith minimum cost(
Approach 1
A 13 B 1 ! 7 C
E 2
Approach 1
A # B
C "
1 D 3 F 2 E
.n this &a/ &e can %ra& all possible combination that covers all the cities an% 'in% the one &ith minimum cost( Drawbacks
Not efficient
Time Consuming Need algorithm to draw all possible combination and find the one with the minimum cost.
Approach 2
Approach 2
A 13 B # C
Approach 2 A 13 B 1 D C
B A # D C 1
Approach 2 A # 7 1 D
C " E
A # 1 C
Approach 2 A B A
Approach 2
A # B
1 D 2 F E
Approach 2
A 13 7 #
C " E 2 F
1 D
Approach 2
A # B 7
C "
1 D 3 F ! 2 E
A # B 7
1 D 3 F 2 E
1a/ o' connecting the cities so that a compan/ incurs a minimum cost 'or telephone line is
!C
!"
!#
!$
!%
6 U 5 4 3 0 A 2 )
.ade by Sonam .ittal