Algorithm Design | Approximation Algorithm | Traveling Salesman Problem with Triangle Inequality

EduSyl
14 May 202425:50

Summary

TLDRThis video script delves into the Traveling Salesman Problem (TSP), focusing on an approximation algorithm technique using the triangular inequality. It explains the TSP, where a salesman must visit a set of cities and return to the origin, and introduces the concept of Hamiltonian cycles. The script discusses the complexity of TSP, which is part of NP-complete problems, and outlines an approach to simplify the problem using the triangular inequality to create an approximation algorithm. The method involves creating a minimum spanning tree (MST) using Prim's algorithm, then refining the solution by applying the triangular inequality to reduce the cost. The script also covers the theoretical aspect, explaining how the approximation algorithm provides a solution that is at most twice the optimal cost, hence a 2-approximation algorithm. The time complexity of the algorithm is polynomial, making it a feasible approach to solving TSP.

Takeaways

  • 🧳 The video discusses the Traveling Salesman Problem (TSP) and its solution using an approximation algorithm based on the triangular inequality.
  • πŸ” TSP is a well-known problem in computer science that is part of the NP-complete class, implying that finding an exact solution can be computationally intensive.
  • πŸ“š The approximation algorithm uses the concept of triangular inequality to simplify the problem and make it more approachable in polynomial time.
  • πŸ“ˆ The script introduces the concept of a Hamiltonian cycle, which is a closed loop on a graph that visits each vertex exactly once and returns to the starting vertex.
  • 🌐 The algorithm starts by selecting any vertex as a root and then constructs a minimum spanning tree (MST) using Prim's algorithm, which is efficient and suitable for this purpose.
  • πŸ“ The definition of the cost of a cycle in TSP is given as the sum of the costs of all edges within the cycle, and the goal is to minimize this cost.
  • πŸ“‰ The triangular inequality states that for any three vertices u, v, and w, the direct cost from u to v should be less than or equal to the cost of going from u to w and then w to v.
  • πŸ”„ The script explains that by applying the triangular inequality, the algorithm iteratively removes edges that do not contribute to the optimal solution, thus approximating the TSP.
  • πŸ“Š The video references a theorem that the approximation algorithm provides a solution that is at most twice the cost of the optimal solution (2-approximation).
  • πŸ•’ The time complexity of the algorithm is polynomial, specifically O(e log V) or O(V + e log V), where e is the number of edges and V is the number of vertices, making it computationally feasible.

Q & A

  • What is the Traveling Salesman Problem (TSP)?

    -The Traveling Salesman Problem (TSP) is an algorithmic problem where a salesman is given a list of cities and must determine the shortest possible route that allows him to visit each city once and return to his original city. It is a well-known problem in the field of combinatorial optimization and is known to be NP-hard.

  • Why is the TSP considered a part of NP complete or NP hard?

    -The TSP is considered NP hard because it is a problem whose solutions can be verified in polynomial time, but finding the solution is computationally intensive and requires exponential time in the worst case, making it infeasible to solve for large instances.

  • What is a Hamiltonian cycle and how is it related to TSP?

    -A Hamiltonian cycle is a closed loop on a graph where every node (city, in the context of TSP) is visited exactly once. It is related to TSP because the goal of TSP is to find the shortest Hamiltonian cycle that visits all given cities and returns to the starting city.

  • What is the purpose of using the triangular inequality in the TSP approximation algorithm?

    -The triangular inequality is used to simplify the problem and make it easier to solve in polynomial time. It helps in creating an approximation algorithm for TSP by ensuring that the direct distance between two points is less than or equal to the sum of the distances through any third point, thus avoiding inefficient routes.

  • How does the approximation algorithm using triangular inequality work in the context of TSP?

    -The approximation algorithm starts by selecting any vertex as a root and then creating a minimum spanning tree (MST) from that vertex. After the MST is formed, a Hamiltonian cycle is constructed by visiting each vertex in pre-order and applying the triangular inequality to ensure the shortest paths are chosen, resulting in an approximate solution to the TSP.

  • What is the significance of the minimum spanning tree (MST) in the approximation algorithm for TSP?

    -The minimum spanning tree is significant because it connects all the vertices with the minimum possible total edge weight. It serves as a foundation for the approximation algorithm by providing a starting point for constructing a Hamiltonian cycle that aims to be as close to the optimal TSP solution as possible.

  • What does the term 'full work' refer to in the context of the TSP approximation algorithm?

    -In the context of the TSP approximation algorithm, 'full work' refers to the process of traversing all the vertices in a pre-ordered manner, effectively creating a cycle that visits each vertex twice. This is used to apply the triangular inequality and find a more optimal path.

  • What is the meaning of a 'two-approximation algorithm' for TSP?

    -A 'two-approximation algorithm' for TSP is an algorithm that provides a solution that is at most twice the cost of the optimal solution. It means the algorithm guarantees that the path length it finds will not be more than twice as long as the shortest possible path.

  • How is the time complexity of Prim's algorithm relevant to the TSP approximation algorithm?

    -The time complexity of Prim's algorithm, which is used to create the minimum spanning tree in the TSP approximation algorithm, is relevant because it indicates the efficiency of the algorithm. Prim's algorithm has a time complexity of O(E log V) or O(V^2), making it a polynomial time algorithm suitable for the approximation approach.

  • What are the naming conventions used for different components of the TSP approximation algorithm as described in the script?

    -The naming conventions used in the script are as follows: 'H*' denotes the optimal tour, 'CT' represents the cost of the minimum spanning tree, 'CW' is the cost of the full work, and 'CH' represents the approximate cost of the Hamiltonian cycle obtained after applying the triangular inequality.

Outlines

00:00

🧳 Introduction to the Traveling Salesman Problem and Approximation Algorithm

The video introduces the Traveling Salesman Problem (TSP), a classic algorithmic problem in the field of computer science. The speaker discusses using an approximation algorithm to simplify the TSP, which is known to be NP-hard. The approximation algorithm leverages the triangular inequality to find a solution in polynomial time. The concept of a Hamiltonian cycle, a closed loop that visits each vertex once and returns to the origin, is also explained as fundamental to solving the TSP.

05:02

πŸ“ Applying Triangular Inequality in Approximation Algorithms

This paragraph delves into the specifics of using the triangular inequality to create an approximation algorithm for the TSP. The triangular inequality principle is explained, where the direct distance between two points (U to V) is compared with the sum of the distances via an intermediary point (U to W and W to V). The algorithm selects the shorter path, which aids in finding a near-optimal solution for the TSP. The paragraph also references Cormen's 'Introduction to Algorithms' as a resource for further understanding.

10:03

🌳 Constructing a Minimum Spanning Tree for TSP Approximation

The speaker outlines the process of creating a minimum spanning tree (MST) as part of the approximation algorithm for TSP. Starting with an arbitrary vertex as the root, the algorithm extends the tree by adding edges, ensuring the total weight is minimized. Two algorithms for MST, Prim's and Kruskal's, are mentioned, with Prim's algorithm being chosen for its sequential edge addition, which aligns with the step-by-step nature of the approximation process.

15:03

πŸ”„ Full Work and Triangular Inequality in TSP

The concept of 'full work' is introduced, which involves visiting each vertex in a pre-order sequence, effectively creating a cycle. This cycle is then optimized using the triangular inequality to remove less efficient paths, thus improving the approximation's accuracy. The paragraph emphasizes the iterative nature of this process, where the full work is refined to better approximate the optimal TSP solution.

20:04

πŸ“Š Theoretical Foundation of the 2-Approximation Algorithm

The video script provides a detailed explanation of the theoretical underpinnings of the 2-approximation algorithm for TSP. It presents mathematical models and proofs to demonstrate that the cost of the approximate solution is at most twice the cost of the optimal solution. The notation used in the script, such as H* for the optimal tour and CT for the minimum spanning tree, helps to formalize the proof and establish the efficiency of the approximation method.

25:05

πŸ”’ Time Complexity and Conclusion of the Approximation Method

The final paragraph wraps up the discussion by emphasizing the polynomial time complexity of the approximation algorithm, which is crucial for its practical application. The speaker mentions the time complexity of Prim's algorithm as O(e log V), where e is the number of edges, and V is the number of vertices. The use of triangular inequality is highlighted as a key factor in achieving this polynomial time complexity, concluding the explanation of the approximation method for the TSP.

Mindmap

Keywords

πŸ’‘Traveling Salesman Problem (TSP)

The Traveling Salesman Problem (TSP) is a classic algorithmic problem in the field of computer science and operations research. It focuses on finding the shortest possible route for a salesman who needs to visit a set of cities and return to his original city, traveling through each city exactly once. In the video's context, TSP is central to the discussion as the problem for which an approximation algorithm is being developed using the concept of triangular inequality.

πŸ’‘Approximation Algorithm

An approximation algorithm is a type of algorithm that finds a solution that is close to the optimal solution but does not necessarily guarantee the best possible outcome. In the video, the approximation algorithm is used to simplify the TSP by leveraging the triangular inequality, making it more computationally feasible to solve within polynomial time, which is crucial for NP-hard problems like TSP.

πŸ’‘Triangular Inequality

Triangular inequality is a principle from geometry stating that the direct distance between two points is always less than or equal to the sum of the distances from those points to a third point. In the script, triangular inequality is used to create an approximation algorithm for TSP, helping to determine the most efficient path by eliminating longer routes that can be replaced by shorter direct paths.

πŸ’‘NP-Complete

NP-Complete is a complexity class in computer science that includes decision problems which are at least as hard as the hardest problems in NP. The term is used in the script to describe the difficulty of the TSP, indicating that it is a particularly challenging problem to solve optimally due to its computational complexity.

πŸ’‘Hamiltonian Cycle

A Hamiltonian cycle is a concept from graph theory where a closed loop in a graph visits each vertex exactly once. In the video, the Hamiltonian cycle is integral to understanding TSP, as the goal is to find such a cycle that represents the shortest possible route for the salesman to travel.

πŸ’‘Minimum Spanning Tree (MST)

A Minimum Spanning Tree is a subset of the edges of a connected, undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. In the script, the creation of an MST is a step in the approximation algorithm for TSP, helping to establish a baseline for the shortest connections between cities.

πŸ’‘Prim's Algorithm

Prim's Algorithm is a greedy algorithm used to find the minimum spanning tree for a connected, undirected graph. In the video, Prim's Algorithm is specifically mentioned as the method used to create the MST, which is a foundational step in the approximation algorithm for solving TSP.

πŸ’‘Pre-order Traversal

Pre-order traversal is a tree traversal method where the node is visited before its children, following a specific order: the node itself, then its left subtree, and finally its right subtree. In the script, pre-order traversal is used in the context of constructing the Hamiltonian cycle for the TSP solution.

πŸ’‘Full Work

In the script, 'full work' seems to refer to the process of visiting each vertex in a way that respects the triangular inequality, ensuring that no unnecessary detours are made. It is a step in the approximation algorithm where all possible routes are considered before applying the triangular inequality to simplify the path.

πŸ’‘Time Complexity

Time complexity is a measure of how long an algorithm takes in terms of the amount of input. It is often expressed using Big O notation. In the video, the time complexity of Prim's Algorithm, which is used to create the MST, is discussed as being polynomial time, indicating that the approximation algorithm for TSP is efficient and can be solved in a reasonable amount of time.

Highlights

Introduction to the Traveling Salesman Problem (TSP) with triangular inequality using approximation algorithm technique.

Explanation of approximation algorithm and its application to simplify TSP to a polynomial time problem.

TSP's classification as part of NP-complete, highlighting its computational complexity.

Overview of Hamiltonian cycle concept and its relevance to TSP.

Detailed description of the TSP, emphasizing the need to return to the starting city after visiting all others.

Introduction of triangular inequality as a method to create an approximation algorithm for TSP.

Example of applying triangular inequality to choose the most cost-effective path in TSP.

The selection process for any vertex as a starting point in the approximation algorithm.

Creation of a minimum spanning tree (MST) as a step in the approximation algorithm using Prim's algorithm.

Explanation of the list of vertices and their order based on pre-order traversal.

Concept of full work in TSP to ensure all vertices are visited according to triangular inequality.

Process of completing the triangle inequality to approximate the TSP solution.

Real-life example of approximation versus optimal solution in delivery scenarios.

Theorem and proof of the 2-approximation algorithm for TSP using triangular inequality.

Mathematical models and expressions used to prove the approximation algorithm's effectiveness.

Discussion on the time complexity of Prim's algorithm and its polynomial nature.

Final summary of the approximation methodology using triangular inequality for TSP.

Transcripts

play00:00

hello everyone welcome to edil in this

play00:02

video we are going to discuss about

play00:04

traveling salesman problem with

play00:06

triangular inequality using

play00:09

approximation algorithm technique okay

play00:11

the approximation basically we are using

play00:13

is using triangular unquality how to

play00:16

find the traveling salesman problem to

play00:18

be easier towards some polinomial time

play00:21

how do we expect okay because traveling

play00:24

salesman is a part of NP complete or

play00:26

somewh you can find it out in NP hard

play00:29

also so but in general you can say it

play00:32

lies between NP hard to NP complete but

play00:35

maximum uh Network stops I found like

play00:38

it's a part of NP complete okay so those

play00:43

who are new kindly watch the previous

play00:45

videos uh next we'll start with the

play00:47

traveling salesman problem so your

play00:50

traveling salesman problem is a problem

play00:52

through which I must tell you like uh we

play00:55

have already completed reduction in

play00:57

detail so Hamilton Cy

play01:02

we should introduce what is this suppose

play01:04

you start with uh

play01:07

vertex I'm just starting with a b c and

play01:11

d okay suppose this is undirected graph

play01:16

because in general whenever you say uh

play01:19

traveling salesman problem so each

play01:21

Vortex is considered as a CT okay so a

play01:24

person is going to travel all the city

play01:26

and when he or she started from a

play01:29

position he or she should have to come

play01:32

back to that particular position this is

play01:34

what the traveling salesman problem is

play01:36

so why we introduce hamiltonan cycle

play01:38

this is I'm just repeating but this part

play01:40

you can the full detail video is there

play01:42

in reduction you can check that one and

play01:45

you can understand like how the

play01:47

traveling salesman is working fine okay

play01:50

so for we introduced hamiltonan cycle or

play01:54

hamiltonan circuit you can say suppose

play01:56

you started from a you can reach B you

play02:00

can reach C then you can reach D again

play02:04

you can reach a this is one point or you

play02:06

can start because though it is

play02:08

undirectional undirected means it's a

play02:10

bidirectional okay so you can start with

play02:12

a to d d to C D to b or you can switch

play02:17

to uh B to a clear there are two ways

play02:20

you can definitely start from a and

play02:22

start end at a also okay so for that

play02:25

reason we are introducing hamiltonan

play02:28

cycle okay or Hamilton circuit this is

play02:31

what we have already discussed now our

play02:34

main target is then why we use for

play02:37

approximation the the basic question

play02:40

okay so uh this is the definition as for

play02:42

the definition which it is written like

play02:44

for a suppose you are trying to you you

play02:47

just converted a cycle like here it is

play02:49

started and you just trying to convert

play02:53

that one up to you know you try to count

play02:55

this a this is what a is okay a cycle is

play02:58

created now the cost cost if you want to

play03:00

find out C stands for the cost which is

play03:03

a sigma because all the uh ages

play03:06

whichever you have connected like with

play03:08

certain u and v with the vertices

play03:11

whatever the edes you have connected or

play03:13

might be within the cycle you just count

play03:16

that one or you just some add that one

play03:18

and this addition of all the cost of

play03:22

Ages is called as the small that should

play03:25

be minimum the

play03:26

minimum it should be minimum okay

play03:30

then only you can say this is your tsp

play03:34

okay but this is sometime hard for us to

play03:37

find out in case of reduction we have

play03:40

set some rule here it is written and uh

play03:44

if you are not restricted the tsp

play03:47

restricted in the sense like if you have

play03:49

not certain if have not framed any rules

play03:52

for that one tsp is too hard to find out

play03:56

okay so in in reduction we said all the

play03:58

distance should be one then hamiltonian

play04:00

cycle we run and we get it within a poal

play04:03

time so this is what exactly we studied

play04:06

like uh that is what we are trying to

play04:08

find out the minimum with the problem

play04:11

exactly what exactly we focused here we

play04:14

are not keeping all the distance as one

play04:17

or two or some same distance is not

play04:20

there here the distance could be

play04:22

different but we are introducing

play04:25

triangular or triangle inequality okay

play04:28

triangle inequality we are using through

play04:31

which we are creating an approximation

play04:35

algorithm for tsp to get the optimal

play04:38

solution for it okay next triangle

play04:42

inequality means for this example I've

play04:44

just kept one example here suppose you

play04:47

want to move from U to V there is one

play04:50

way another way also this one clear so

play04:53

how do you pick which one is good for

play04:55

you like suppose u2v cost u2v means

play04:58

direct uh you have two options like from

play05:01

direct you have to check whether it is

play05:03

less than Cost U to W and cost this cost

play05:08

and this cost it represents okay so

play05:11

whether it is equal less than equal to

play05:14

this one or not if it is less than this

play05:17

so we will pick UV instead of U to W and

play05:21

W to V this is what the triangle

play05:24

inequality if it is more if the distance

play05:27

is more so definitely we'll pick this

play05:29

one like U to V we will come and sorry U

play05:32

to W then W to V we are reaching if you

play05:36

will find it out by comparing this one

play05:38

so definitely stop accepting this row

play05:42

and we will pick this one CLE this is

play05:44

what a triangle inequality it represents

play05:47

it uh then using triangle uh inequality

play05:51

can we reduce or can we give such

play05:55

approximation algorithm or not that is

play05:58

our aim and objective here clear so you

play06:01

can check approximation algorithm we are

play06:04

going to use so I'll start from this

play06:07

book I'm following the book uh written

play06:09

by Corman introduction to algorithm you

play06:11

can check in the description also the

play06:14

book and uh the textbook and the

play06:17

reference book everything I have

play06:18

mentioned there next uh what text are

play06:23

select any vertex you this is not always

play06:25

mandatory no you should start from the

play06:27

end you can start from the bottom

play06:28

nothing you you can start any vertex

play06:30

select any vertex from the vertex given

play06:34

okay and keep that was a root First Step

play06:38

Second Step what it says we are just

play06:40

creating a minimum spanning tree those

play06:43

who are new kindly watch the full detail

play06:45

video there in a minimum spinning tree

play06:48

okay uh so here uh we kept the root R

play06:53

based on that we created the minimum

play06:55

sping tree as we have already discussed

play06:58

whenever we studied the minimum spanning

play07:00

tree there are two approaches or two

play07:01

algorithms we discussed one is prims

play07:04

algorithm other is cuscal algorithm so

play07:06

here this is a PR algorithm we going to

play07:08

use so because we are trying to find out

play07:11

one by one with the ages that's why we

play07:13

fixed up with the PES algorithm we

play07:16

detail analysis will be done don't worry

play07:18

about it first we will uh read each and

play07:21

every sentence written there because

play07:23

algorithm is a comprises of the

play07:25

solutions that's why we first starting

play07:27

with the solution then we are going

play07:28

towards the problem

play07:30

clear next H is a list of vertices what

play07:33

exactly is our list of vertices you can

play07:36

say ordered accordingly when they are

play07:39

first visited in pre-order like whenever

play07:42

we have already studied to visit a tree

play07:45

there are three different ways one or

play07:46

three different order we have studied

play07:48

earlier in data structure one is

play07:51

pre-order in order post order there are

play07:54

three ways pre-order means we initially

play07:57

we started visiting of the node for the

play07:59

first first time in order means for the

play08:01

second time post order means third time

play08:04

clear we have already discussed in the

play08:06

data structure video there it is clearly

play08:09

mentioned so how to complete to the

play08:12

pre-order first we have completed a

play08:14

pre-order like H we will completely say

play08:17

that one and return the hamiltonian

play08:20

cycle hamiltonian cycle means we will

play08:22

not repeat the same age again okay we

play08:27

will say once I'll start with like the

play08:30

the example I must tell you like we will

play08:32

start from this end you can start your

play08:35

movement but you will end up with this

play08:38

one this is what your hamiltonian cycle

play08:40

okay like you will definitely end at

play08:43

this

play08:44

position wherever you start you will

play08:47

definitely end you can definitely end it

play08:50

this position this is Hamilton cycle we

play08:52

have discuss that that is what the

play08:54

fourth line says clear so I hope you

play08:57

understood what exactly it is written

play09:00

now based on the example there in the

play09:02

book I'm just going to tell you that one

play09:04

this a represents this is a graph given

play09:07

to us with uh you can say the weight are

play09:10

different but here the weight is not

play09:13

mentioned in the uh book that's why I'm

play09:15

not you know adding that one so out of

play09:19

this we are going to create MST minimum

play09:23

spanning tree using prims why prims

play09:25

because you can take uh the help of

play09:28

crull also not an issue but they have

play09:30

taken the PES okay so once the PES they

play09:33

have collected like they started a as a

play09:36

root from that one they just created an

play09:40

MST okay next MST is a tree that we have

play09:44

already discussed this C represents is a

play09:47

full

play09:49

work full

play09:54

work full work means we are going to

play09:58

just cover all all the vertices why

play10:00

because we are trying to find out the

play10:03

triangle inequality suppose you must say

play10:05

like whether I if I'm coming to C to B

play10:09

then I'm going towards C to H whether

play10:12

this H is greater than this is or not if

play10:16

this is greater than so I must have to

play10:19

remove that one and I'll select this one

play10:21

for for triangular inequality for

play10:23

triangular

play10:25

inequality or triangle inequality

play10:29

I'm just writing in short for triangular

play10:33

inequality we are actually doing the

play10:35

full work okay next once it is done so

play10:40

we have completed triangle inequality so

play10:44

you can say this is your

play10:51

approximate tsp traveling sales person

play10:54

or traveling salesman problem

play10:57

okay this is your approximate so instead

play11:00

of B2 H C2 B then C2 H clear using

play11:06

triangle

play11:07

inequality this is your optimal

play11:13

optimal or best you can say

play11:18

tsp mean you know the problem optimal

play11:21

how do you define in real life you know

play11:24

that one is it will take at least 2

play11:26

minutes to cover everything or 2 hours

play11:28

to cover every CT is so you know that

play11:30

this is optimal suppose you uh inform a

play11:33

person to in a real life basically how

play11:36

you will use that one optimal means the

play11:38

experience fellow experience fellow

play11:40

means I have already served the root

play11:43

everything I know two hours is enough

play11:45

but sometimes a person is coming I I I

play11:49

hired him or her for delivery purposes

play11:54

might be he or she will take like I'll

play11:56

tell like which one that you should have

play11:57

to cover first how you will complete

play11:59

everything I instructed everything but

play12:02

the new person he see tries to

play12:05

understand tries to tackle all the paths

play12:08

within less time might be it's near

play12:10

optimal I told like 2 hours is enough

play12:13

might be for him or her it took 3 hours

play12:16

so this is what a real life example of

play12:18

approximation with the optimal solution

play12:20

optimal solution like here what they

play12:22

said like A2 B then B2 H instead of H2 D

play12:28

what they started h2f this is the

play12:30

optimal answer okay which is represented

play12:34

what format that we will discuss this is

play12:36

how we have completed how it is working

play12:39

clear now for the theorem for the

play12:41

theorem how to prove it just check it in

play12:45

general uh University type of exams this

play12:48

type of questions could be come like how

play12:50

to verify it is two approximation

play12:53

algorithm clear so it is saying uh

play12:56

approx tsp t is polom time to

play13:01

approximation algorithm for traveling

play13:04

salesman problem using triangle

play13:06

inequality using triangle inequality we

play13:09

are getting a two approximation means

play13:12

two times it means 2

play13:17

times

play13:19

more

play13:21

than

play13:23

the

play13:26

optimal value or optimal cost two time

play13:31

more that that is what it represents two

play13:33

approximation algorithm that we have

play13:36

already discussed C

play13:39

star C by C

play13:43

star equal to row of n that row

play13:47

represents two that is what we have

play13:50

already discussed to

play13:56

approximation then how to

play13:59

prove this one try to understand now

play14:02

clear so here H star denotes optimal

play14:06

tour we have done the optimal tour H

play14:09

star represents so this is our H star or

play14:13

cost of H star you can say which is the

play14:17

smallest for a timing because this is

play14:19

our optimal one okay next T represents

play14:24

the spanning tree which you have

play14:26

completed for the first time it is

play14:28

represented in the line two line two

play14:30

means this one compute minimum spanning

play14:32

tree whenever we have computed this one

play14:35

is cost of spanning tree this is what CT

play14:40

represents clear CT CH

play14:44

star now for full work we'll decide full

play14:48

work is represented as W clear so this

play14:52

one is cost of w is represented as the

play14:58

total cost or total weight covered by

play15:03

the full work

play15:04

okay

play15:06

next this H represents which is obtained

play15:09

by deleting the full work deleting the

play15:12

vertices from the full work represents

play15:14

the

play15:15

approximate cost of

play15:24

H

play15:27

okay these are just the naming

play15:29

conventions first we'll try to

play15:31

understand what it does whenever we say

play15:35

optimal one optimal is always greater

play15:38

than the spanning tree why here you can

play15:41

say whenever you are creating the tree

play15:44

clear this is for one time one Ed should

play15:46

be connected if there is a cycle

play15:48

definitely I must tell you this is not a

play15:51

Tre this is just a graph so minimum

play15:52

spanning tree means we are just

play15:54

converting the graph into tree means we

play15:56

are trying to remove all the edges which

play15:59

makes the cycle clear so here in this

play16:02

example here is a cycle so definitely

play16:05

what it says so this CH star is

play16:08

definitely greater than equal to the CT

play16:12

C might be it is equal but it is should

play16:14

be always greater why because we can

play16:17

have a cycle clear when we are creating

play16:20

the cycle we cannot guarantee about the

play16:23

cost minimum spanning tree is always

play16:26

giving us the minimum value but here

play16:29

whenever we include the cycle we cannot

play16:31

always guarantee about the minimum cost

play16:34

or minimum weight that is what we said

play16:37

this is just one first expression or

play16:40

mathematical model we designed or

play16:42

developed which is 35.4 we named that

play16:45

one clear I hope it is clearly

play16:47

understood when we start with the full

play16:49

work full work means we started from a

play16:53

we are completing B like we are just

play16:56

doing the pre-ordering which we have

play16:58

said this one pre-ordering we are just

play17:00

trying to go for the pre-ordering of the

play17:02

full work like we started with a then b

play17:05

c then B then H then again B so I must

play17:10

write like how we are covering a then B

play17:14

then C then again

play17:16

B then H then H to again B then

play17:23

a then

play17:25

D then e f again e then G then D then

play17:33

a clear this is what we are doing in a

play17:37

full work it is also written there a b c

play17:42

BH you can say a b c BH clear this is

play17:46

what ba means this is exactly what I I'm

play17:50

just writing this one I was just writing

play17:52

this one it is written in the book this

play17:55

is what a full work we are doing the

play17:57

pre-ordering of it

play18:00

clear like we have done just for what

play18:03

reason just for find the triangle

play18:05

inequality for finding triangle

play18:09

inequality for triangle

play18:13

inequality that's why we are just

play18:15

covering all the one whichever is

play18:17

greatest for us we trying to remove that

play18:19

one clear

play18:22

next so for that CW which is our full

play18:26

work definitely 2 *

play18:29

we are doing it two times how you can

play18:32

say for A to B we have covered clear a B

play18:35

to C we have covered for the first time

play18:37

now then c2b we are covering again now

play18:41

this is for one time this is for the

play18:42

second time so you can say again for B

play18:46

to H we have covered for one time again

play18:49

H to B whenever we are coming this is

play18:50

for the second time clear so whenever

play18:54

I'm just coming towards this here it is

play18:56

for the first time here it is for the

play18:58

second time so indirectly we are just

play19:01

covering all the paths second time means

play19:06

this is what it represent CW full

play19:09

work CW is 2

play19:12

C to cost of t means the spanning tree

play19:16

it is two times spanning tree okay the

play19:19

cost of spanning tree two times we are

play19:21

covering because of this region A to B

play19:24

we have covered B to C is the first time

play19:26

but whenever we coming back clear C2 B

play19:29

it covers again the same uh AG cost or

play19:33

the cost or the weight is covering again

play19:36

that is what it represents

play19:38

clear next if we equate and we name that

play19:42

one 35.5 clear if we equate that one so

play19:46

we will get this result as uh the the

play19:49

full work which we did is equal to is

play19:53

less less than equal to the cost of the

play19:57

optimal answer which which we should get

play19:59

you can equate that the previous two one

play20:02

which we equate through that we have

play20:04

finalized the answer as this clear next

play20:07

what exactly we going to do we are now

play20:10

saying whenever we are doing the uh

play20:14

first visit pre-order pre-order case

play20:18

what exactly Tells A B C then H then a d

play20:23

this is what it represents a b c h then

play20:26

d e FG this is for the pre PR order this

play20:29

is pre-order that we have completed one

play20:32

okay so once we have done

play20:35

it so here you can check that one D

play20:40

clear once we covered that one with F2 G

play20:44

then G2 a there is another one like we

play20:46

are going to the that one but how we

play20:48

cover a b then B to C then C2 H H2 D D2

play20:56

e E2 F F2 G this is what it is written

play21:00

okay this is what we are getting just

play21:04

deleting such notes which are giving us

play21:08

maximum results using triangular

play21:10

inequality or triangle inequality we did

play21:13

that one the triangle inequality we

play21:15

applied that one and we got certain

play21:18

results definitely those results are

play21:21

less than the full work why because we

play21:23

are removing from the full work this is

play21:26

our full work and we removed the full

play21:28

work we have focused on minimizing that

play21:31

one so definitely when we focusing on

play21:33

minimizing that one so it is less than

play21:36

here it is not we are saying it is two

play21:37

times definitely we'll get either equal

play21:40

to sign but that should be less so this

play21:43

represents this is our optimal this is

play21:45

our approximate value this is our full

play21:48

work full work is less than equal to

play21:50

this one clear whenever you equate uh we

play21:53

name that one 37

play21:55

35.7 so whenever you equate 3 5.6 with

play21:59

35.7 because our Target is two way

play22:02

approximation how it does like you can

play22:04

say here CW here CW you just replace the

play22:07

CW or the two CH there so we got the

play22:11

value is this one this represents the

play22:14

approximation value is 2 times greater

play22:18

than the optimal answer this is what it

play22:20

says clear so this

play22:22

says this ISS two approximation clear

play22:27

two approximation

play22:34

I'm writing this it to

play22:41

approximation because CH represents the

play22:45

cost of approximation and C A Star is

play22:47

optimal answer the optimal answer is two

play22:50

times more clear so that's why what is

play22:53

we what exactly we saying so uh the

play22:56

answers which we are expecting here is

play23:00

two times more than the optimal answer

play23:02

which we are expecting that's why we are

play23:05

saying it is two approximation algorithm

play23:07

using triangle inequality clear so two

play23:10

approximation as we have already told

play23:12

you like this one C is two times more

play23:16

than the C star okay that is what it is

play23:18

written suppose I'm just writing

play23:21

c 2 * C star this is what we are getting

play23:26

this result so this is what we are

play23:28

expecting this c h now to

play23:33

c h

play23:35

star clear this is what two *

play23:39

approximation is so I hope it is clearly

play23:43

understood by you how we have completed

play23:46

with the approximation methodology we

play23:49

have used the approximation indirectly

play23:51

we said that triangle inequality how it

play23:54

helps us to get a polom time though we

play23:57

expecting the polom time here the prims

play24:00

algorithm we have run so here others are

play24:02

not exactly much time we expecting for

play24:04

the prims algorithm PR algorithm we can

play24:07

say the time complexity is e v log V

play24:13

also we are saying b of e log V also we

play24:16

are saying sometimes you can say it is

play24:20

also r b of V plus e why because we are

play24:24

just removing e Vortex with the ages

play24:27

because we started with a Connect One

play24:29

log V 2 this is what the time complexity

play24:35

of Pol you know MST Pol PRS algorithm so

play24:40

that's why we can say that complexity is

play24:42

this one which is polom that's why

play24:45

though it's polinomial one for us so we

play24:48

must say the complexity of the algorithm

play24:52

is polom so I'm just writing it clearly

play24:55

time complexity

play24:59

big of e you can say you can use mod

play25:05

also not an

play25:06

issue you can use mode or you cannot use

play25:09

mode it it's up to you by the way

play25:12

clear next we

play25:16

of

play25:19

uh we of V +

play25:23

e then log V this also some someone can

play25:28

write in this order also not an issue

play25:31

but we must say this is the Pol

play25:35

polinomial time it is taking but we are

play25:37

taking the help of triangle inequality

play25:40

this is what we did with the

play25:42

approximation so I hope it is clearly

play25:44

understood by you if any doubt you will

play25:46

be having please comment below thank you

play25:48

for having a good day

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Traveling SalesmanApproximation AlgorithmTriangular InequalityNP-CompletePolynomial TimeHamiltonian CyclePrim's AlgorithmData StructuresOptimizationAlgorithm Design