Example 4 Show that the Square Packing SP








- Slides: 8
• 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 = {s 1, s 2, . . . , 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 1
3 -Partition Problem Given a list A = {a 1, a 2, . . . , a 3 z} of 3 z positive integers such that sum of all numbers is z. B and B/4 < ai < B/2 for each 1 i 3 z. 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 2
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 3
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 = {a 1, a 2, …, 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 4
• 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 5
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(n. B) Young CS 530 Ad. Algo. D&A NP-Completeness 6
• 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 7
• 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(n 3) Young CS 530 Ad. Algo. D&A NP-Completeness 8