0% found this document useful (0 votes)
8 views6 pages

Toc Unit5

The document discusses tractable and intractable problems in computer science, defining tractable problems as those solvable in polynomial time and intractable problems as those requiring super-polynomial time. It highlights the Traveling Salesman Problem (TSP) and the partition problem as examples of intractable problems, emphasizing their NP-hard and NP-complete classifications respectively. The document also mentions the use of approximation algorithms for TSP and the real-world applications of the partition problem.

Uploaded by

Aditya Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Toc Unit5

The document discusses tractable and intractable problems in computer science, defining tractable problems as those solvable in polynomial time and intractable problems as those requiring super-polynomial time. It highlights the Traveling Salesman Problem (TSP) and the partition problem as examples of intractable problems, emphasizing their NP-hard and NP-complete classifications respectively. The document also mentions the use of approximation algorithms for TSP and the real-world applications of the partition problem.

Uploaded by

Aditya Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

In computer science, tractable and intractable problems are terms used to describe the

feasibility of solving problems within a reasonable amount of time. Here’s a breakdown of


what each term means:

Tractable Problems

Aspect Description
Problems that can be solved in polynomial time (i.e., their time complexity
Definition
can be expressed as a polynomial function of the size of the input).
Time
Polynomial time (e.g., O(n), O(n^2), O(n^3))
Complexity
Sorting algorithms (e.g., merge sort), finding the shortest path (e.g.,
Examples
Dijkstra's algorithm), searching (e.g., binary search)
Considered "feasible" or "efficiently solvable" because the computation time
Feasibility
grows at a manageable rate as the input size increases.
Class Includes problems in the class P (Polynomial Time).
Impact Solutions are practical for large inputs.

Intractable Problems

Aspect Description
Problems for which no polynomial-time algorithms are known, and are often
Definition
believed to require super-polynomial time to solve.
Time
Super-polynomial time (e.g., exponential time, factorial time)
Complexity
Examples Traveling Salesman Problem, 3-SAT, integer factorization
Considered "infeasible" or "impractical" for large inputs because the
Feasibility
computation time grows very quickly as the input size increases.
Includes problems in NP (Nondeterministic Polynomial time) and
Class
specifically NP-Hard and NP-Complete problems.
Aspect Description
Solutions are impractical for large inputs; approximate or heuristic solutions
Impact
may be used instead.

Summary

 Tractable Problems: These are problems that can be solved efficiently (in
polynomial time), making them practical for use even with large inputs.
 Intractable Problems: These problems cannot be solved efficiently (they require
super-polynomial time), making them impractical for use with large inputs.

In practice, for intractable problems, researchers often look for approximate or heuristic
solutions that provide good-enough answers within a reasonable time frame.

 Problem Definition: Given a set of cities represented as vertices in a graph, and distances
between each pair of cities as edge weights, find the Hamiltonian cycle with the minimum
total weight. A Hamiltonian cycle is a path in the graph that visits each vertex exactly once
and returns to the starting vertex.

 Complexity: TSP is a well-known NP-hard problem. This means:

 NP: We can efficiently verify if a given solution (a route visiting all cities) is indeed a
minimum distance route.
 NP-hard: Finding the optimal solution itself is computationally difficult. There's no
known efficient algorithm (polynomial time) that can solve TSP for all problem sizes.
As the number of cities increases, the number of possible routes grows exponentially,
making it intractable to check them all for optimality.

 Approximation Algorithms: Due to its NP-hard nature, we often resort to approximation


algorithms for TSP. These algorithms find solutions that are guaranteed to be within a certain
percentage (or factor) of the optimal solution in polynomial time. Examples include nearest
neighbor heuristic or Christofides algorithm.

 Impact: Understanding TSP's complexity helps us classify similar optimization problems


and design efficient algorithms for practical applications. It highlights the concept of
problems that are easy to verify but hard to solve, a crucial distinction in theoretical computer
science.

Absolutely! Let's look at TSP with a simple graph:

Cities and Distances:

Imagine we have a salesperson visiting 4 cities: A, B, C, and D. The distances between them
are represented in a distance matrix:

City A B C D
A - 5 7 3
B 5 - 6 4
C 7 6 - 2
D 3 4 2 -
Here, the distance matrix shows the cost (distance) of traveling between any two cities.

For example, going from A to B is 5 units, and from C to D is 2 units.

Graph Representation:

This information can be visualized as a complete weighted graph:

Each city is represented by a vertex (node) in the graph.

Edges connect every pair of cities, indicating a possible route between them.

The weight on each edge represents the distance between the connected cities.

Finding the Optimal Route (TSP in Theory):


The problem in TSP is to find the Hamiltonian cycle with the minimum total weight in this graph. A
Hamiltonian cycle is a path that visits each vertex (city) exactly once and returns to the starting
vertex.

In theory, to find the optimal route (shortest cycle), we would need to check every possible
Hamiltonian cycle and calculate its total weight. With 4 cities, there are 4! (4 factorial) = 24 possible
Hamiltonian cycles. We could calculate the total distance for each and pick the one with the
minimum weight.

However, as the number of cities increases, the number of possible Hamiltonian cycles grows
exponentially. For 10 cities, there are 10! = 3,628,800 possibilities, making it impractical to check
them all using a brute-force approach.

TSP as an NP-hard problem:

This is why TSP is classified as NP-hard. While we can verify if a given Hamiltonian cycle is optimal by
simply summing the edge weights (NP), finding the optimal cycle itself becomes computationally
expensive for larger problems (hard).

This example illustrates the concept of NP-hardness in TSP within the theory of computation. Even
for a small graph, finding the optimal solution requires significant effort. In practice, for bigger
problems, we often rely on approximation algorithms that provide good (but not guaranteed
optimal) solutions in a reasonable amount of time.

The partition problem asks whether a given set of positive integers can be divided into two
subsets where the sum of elements in each subset is equal. Here's a breakdown with an
example:

Problem Definition:

Imagine you have a bag of weights: {2, 3, 7, 1}. The partition problem asks if you can divide
these weights into two groups such that the total weight in each group is the same.

Solving the Example:


In this case, the total weight of all weights is 2 + 3 + 7 + 1 = 13. Since 13 is odd, it's
impossible to divide the weights into two groups with equal weight.

 Why? Because each weight is a positive integer, and dividing an odd number into two
equal parts isn't possible.

Solving a partition problem with an even total weight:

Let's say we have a different bag of weights: {1, 5, 11, 2}. Here, the total weight is 1 + 5 + 11
+ 2 = 19. Since 19 is even (divisible by 2), it becomes a candidate for partitioning.

Here's how we can approach this problem:

1. Check for even sum: The first step is always to check if the total sum of all weights
is even. If it's odd, as in our first example, partition is not possible.
2. Target sum: Since the total weight is 19 (even), we can aim to partition the weights
into two subsets where each subset has a sum of 19 / 2 = 9.5. However, since we're
dealing with whole weights, we can rephrase this as checking if a subset exists where
the sum of its elements is exactly 9 (half of the total weight, rounded down).
3. Solution Approach: There are different ways to solve the partition problem. One
approach is dynamic programming, which builds a table to efficiently track if a subset
with a specific sum exists for a given weight set.

In simpler terms, for each weight in the set, we can iteratively check if including that weight
in a subset helps us reach the target sum (9 in our example). This might involve checking if
there's already a valid subset formed by previous weights that, when combined with the
current weight, reaches the target sum.

Complexity of the Partition Problem:

The partition problem is interesting because it's known to be NP-complete. This means:

 NP: Given a specific partition (two subsets with equal sum), we can efficiently verify
if it's a valid partition for the original weight set (by simply adding the elements in
each subset).
 NP-hard: Finding the partition itself is computationally difficult. There's no known
efficient algorithm (polynomial time) to solve the partition problem for all problem
sizes. As the number of weights increases, the number of possible combinations to
explore grows exponentially.

Real-world applications:

While the partition problem might seem abstract, it has applications in various scenarios
where we need to divide resources or tasks into equal groups. For example:

 Resource allocation: Assigning projects to teams with similar workloads.


 Data distribution: Dividing data files across multiple servers for balanced storage
and processing.
 Image compression: Partitioning an image into blocks for efficient compression
techniques.
The partition problem serves as a foundation for understanding NP-completeness and the
challenges of finding optimal solutions for specific computational problems.

You might also like