Presentation is loading. Please wait.

Presentation is loading. Please wait.

Example 4 : Show that the Square Packing (SP) Problem is NP-complete.

Similar presentations


Presentation on theme: "Example 4 : Show that the Square Packing (SP) Problem is NP-complete."— Presentation transcript:

1 Example 4 : Show that the Square Packing (SP) Problem is NP-complete.
Motivation : truck loading, processor allocation problem in a partitionable mesh connected system, the design of VLSI chips and etc. Square Packing Problem Given a packing square S and a set of packed squares L = {s1, s2, ..., sn}. Question : is there and orthogonal packing of L into S? Note : orthogonal packing  the sides of squares are parallel to the vertical and horizontal axes Young CS 530 Ad. Algo. D&A NP-Completeness

2 Note : each group must have exactly 3 numbers
3-Partition Problem Given a list A = {a1, a2, ..., a3z} of 3z positive integers such that sum of all numbers is zB and B/4 < ai < B/2 for each 1  i  3z. Question : Can A be partitioned into z groups such that the sum of all numbers in each group is B. Note : each group must have exactly 3 numbers Proof : Refer to the following research paper Leung, Tam, Wong, Young and Chin, “Packing Squares into a Square”, Journal of Parallel and Distributed Computing, 1990. Young CS 530 Ad. Algo. D&A NP-Completeness

3 Coping with NP-Completeness Problem NP-hard Problem
Note : Refer to Chapter 5 of Garey and Johnson If L' L and L' is an NP-complete problem then L is called NP-hard problem. All NPC problems are NP-hard. Informally, an NP- hard problem is a problem which is at least as hard as an NP-complete problem. Young CS 530 Ad. Algo. D&A NP-Completeness

4 There are some NP-hard decision problems that are not in NP.
Example : Kth Largest Subset Problem is not in NP Instance : Given a set of positive integers A = {a1, a2, …, an}, and two non-negative numbers, B  A and K  2|A|. Question : Are there at least K distinct subsets A’  A such that each subset has total sum >= B. Note : PARTITION problem  Kth Largest Subset Problem Young CS 530 Ad. Algo. D&A NP-Completeness

5 Pseudo-polynomial time algorithm
Note : Refer to Chapter 4 of Garey and Johnson Some NP-complete problem may be solved in "polynomial" time (based on input size and magnitude). Example : PARTITION problem Young CS 530 Ad. Algo. D&A NP-Completeness

6 Dynamic Programming Algorithm :
assume B = (sum of n integers)/2 construct a table of size (approx.) n x B fill in the table row by row for each row, add a new element mark sum of all possible subsets if there is a subset with sum = B, stop. Time Complexity : O(nB) Young CS 530 Ad. Algo. D&A NP-Completeness

7 NP-completeness in the strong sense
Note : Refer to Chapter 4 of Garey and Johnson If L is NP-complete problem in the strong sense, then L cannot be solved by a pseudo-polynomial time algorithm unless P=NP L is NP-complete in the strong sense if L'  L , L' is NP-complete in the strong sense and L is in NP Example : 3-partition problem is NPC in the strong sense. Young CS 530 Ad. Algo. D&A NP-Completeness

8 Solving more restricted problems
If we restricted the problem L to problem L' i.e. L' is a special/restricted case of L, then we may solve L' in polynomial time. For example : PARTITION problem if we assume that each input integer ai  n, where n is the number of input integers, then the pseudo polynomial time algorithm becomes polynomial time algorithm, i.e. O(n3) Young CS 530 Ad. Algo. D&A NP-Completeness


Download ppt "Example 4 : Show that the Square Packing (SP) Problem is NP-complete."

Similar presentations


Ads by Google