Pancake Flipping with Two Spatulas
In this paper we study several variations of the \emph{pancake flipping problem}, which is also well known as the problem of \emph{sorting by prefix reversals}. We consider the variations in the sorting process by adding with prefix reversals other s…
Authors: ** 논문에 명시된 저자 정보는 제공되지 않았다. (원문에 저자명 및 소속이 누락되어 있음) **
P ancak e Flipping with T w o Spatulas Masud Hasan 1 , 3 , A tif Rahman 1 , 4 , M. Sohel Rahman 1 , 2 , 3 , Mahfuza Sharmin 1 , 5 , and Rukhsana Y easmin 1 , 5 1 Department of Computer Science and Engineering Bangladesh Universit y of Engineering and T echnology , Dhak a-1000, Bangladesh 2 Algorithm D esign Group, Department of Computer Science King’s College London, Strand , London WC 2R 2LS, England 3 { masudhas an, msr ahman } @cse.buet. ac.bd 4 atif.bd@gm ail.com 5 { mhfz sharmin, smrity 23 } @yahoo .com Abstract. In this pap er w e study severa l v ariations of the p anc ake fli pping pr oblem , which is also w ell known as the problem of sorting by pr efix r eversals . W e consider the vari ations in the sorting process by adding with prefix reve rsals other similar op erations such as prefix transp ositions and pre- fix transrev ersals. These type of sorting p roblems ha ve applications in interconnection n etw orks and computational biology . W e first study th e problem of sorting unsigned p erm ut ations by prefix reversals and p refix transp ositions and presen t a 3-app ro ximation algori th m for th is problem. Then we give a 2-approximatio n algorithm for sorting by prefix reversals and prefix transreversals . W e also provide a 3-approximatio n algorithm for sorting by prefix rev ersals and prefix transp ositions where t h e op erations are alw ays app lied at the un sorted suffix of the p ermutation. W e further analyze the problem in more practical w ay and sho w quantitativ ely how approximatio n ratios of our algorithms impro ve with th e increase of number of p refix reversals ap p lied by optimal algorithms. Finally , we present exp erimental results to supp ort our analysis. Keywords: App ro ximation algorithms, pancake flipping, sorting by prefix reversals and prefix trans- p ositions, adaptive app ro ximation ratio, interconnection netw ork, computational b iology . 1 In tro duction Given a p er mutation π , a r eversal r e verses a substring o f π , a tr ansp osition cuts a s ubstring o f π a nd pastes it in a different lo ca tio n, and a tr ansr eversal is a transp os ition of a substr ing with a reversal done b efore it is pa sted. In a pr efix reversal/transp os ition/transr ev ersals the corres po nding substring is alwa ys a prefix of π . The p anc ake flipping pr oblem [1–5 ] deals with finding the minimum num ber of prefix reversals (i.e., flips ) required to sort a g iven p ermutation. This pro blem was fir st introduced in 197 5 by [1] which descr ibes the motiv ation of a chef to rea rrang e a s tack of pancakes from the sma llest panca ke on the top to the la r gest one on the bo ttom by grabbing several pancakes from the top with his s patula and flipping them ov er, rep eating them as many times as necessar y . Aside from b eing an interesting combinatorial pro blem, this problem and its v ariations hav e a pplications in in terc onnection netw o rks and computational biology . The num ber of flips required to sor t the stack of n pancakes is the diameter of the n -dimensional p anc ake network [4, 5]. The diameter of a netw ork is the maximum distance b etw een any pair of no des in the netw or k and co rresp onds to the worst co mm unica tio n delay for br oadcasting messa g es in the netw ork [4, 5]. A well studied v ariation of panca ke flipping problem is the burnt p anc ake flipping pr oblem [2 , 4, 5] where each element in the permutation has a sign, and the sign of an element changes with r eversals. Pancake and burnt pancake netw orks hav e b etter diameter a nd b etter vertex degree than the p opular hypercub es [4]. Ther e exists some o ther v aria tio ns of pancake flipping, giv ing different efficien t interconnection ne tw o r ks [2]. A broa der class consisting o f similar sorting pr oblems, c alled the genome r e arr angement pr oblems , are ex- tensively studied in computational molecula r biolog y , wher e the o rders of genes in tw o sp ecies are represented by p ermutations and the problem is to transfor m one into another b y using minim um num b er of pr e-sp ecified rearr angement op erations. In order to explain the existence of ess ent ia lly the same set of genes but differ- ences in their order in differe n t sp ecies, s e veral re a rrang emen t op erations hav e b een suggested, including reversals [6–8 ], blo ck interchange [9], tra nspo sitions [10–12 ], transre versals [13], fission and fusion [14], pre fix transp osition [15], etc. The abovemen tioned sorting problems are mostly NP-complete or their complexity is unknown. Caprar a [16] prov ed that sorting by reversals is NP - hrad, wherea s Heydari and Sudbo rough [17] have c laimed that so rting by prefix r eversals is NP- complete to o. The co mplex it y of sorting by transp osition and so rting by pr efix transp osition is still op en. As a result, many approximation algor ithms are known for each of these pr oblems and their v ariations. A num ber o f authors hav e a lso considered the pr o blem o f sorting per mut a tio ns by using mor e than one rearr angement o pe r ations (r eversals, transp ositions etc.) [18 –20, 13, 21–23], mostly for signed p ermutations. Rahman et.al. [22] studied the problem o f sorting p ermutations by transp ositions and reversals, where they give a n approximation algor ithm with approximation ratio 2 . 83. 1.1 Our results In this paper w e study some v ariations of pancake flipping pr oblem from the view p oint of sor ting p er- m utatio ns . W e consider the pr oblem of sor ting an (unsigned) p ermutation by prefix reversals and prefix transp ositions. W e give a 3-a pproximation alg o rithm for sorting b y prefix reversals and prefix trans po sitions, and a 2-approximation algorithm for sorting b y prefix reversals and prefix transreversals. Exp er imen tal result shows that our algorithms p erfor m muc h b etter in practice. Note that the problem of sorting b y reversals and tr ansp ositions in [22] and the problem of sorting by prefix reversals and prefix tr ansp ositions considered in this paper are not the same a nd they do not imply each o ther. W e also introduce the concept o f forwar d mar ch . The idea o f forward march comes natur ally fro m a greedy a pproach wher e so meone may try to sort the p ermutation from starting to end. While applying prefix reversals and prefix tr a nsp ositions, a pr efix of the given p er m utation may b ecome sor ted. Whenever this happ ens, we mov e forward and apply the next op er ation in the remaining unsorted suffix of the p ermutation. W e g ive a 3-approximation algorithm for this pr oblem which also p erfor ms b etter on average. The ab ove problems that we consider in this pap er are v aria tions of the original pancake flipping pr oblem where the chef has tw o spatulas in his tw o free hands. He ca n either lift some pancakes from the top of the stack and flip them (a pr efix reversal) or he can lift a top p or tion o f the stack with one hand, lift another po rtion fro m the top with the other hand, and place the top p or tion under the seco nd p ortion (a pr e fix transp osition) p ossibly with a flip (a prefix transr eversal). Also, time to time, when a top p ortion of the stack is sorted he c a n remove it fro m the s tack (a forward march). It is worth mentioning that the worst case ratios of our a lgorithms can only be r e alized when an optimal algorithm a pplies no pre fix reversals at all. B ut it is v er y likely that an optimal a lg orithm will apply b oth op erations. K eeping this observ ation in mind, we derive mathematically the equa tions for approximation ratio in terms of the num ber o f prefix r eversals applied by an o ptimal algo rithm. W e o rganize rest of the pap er a s follows. In Section 2 we give the definitions and o ther preliminar ies. In Section 3, 4 , and 5 we pr esent the appr oximation algorithms. In Section 6 w e derive equatio ns for approxi- mation r a tio in terms of num b er of pr efix reversals applied by an optimal alg orithm. In Sectio n 7 we pre s ent our exp er imen tal results. Fina lly , Se c tion 8 co ncludes the pap er. 2 Preliminaries Let π = [ π 0 , π 1 , . . . , π n , π n +1 ] b e a permutation of n + 2 distinct elements where π 0 = 0, π n +1 = n + 1 and 1 ≤ π i ≤ n for each 1 ≤ i ≤ n (the middle n e le men ts of π are to b e sorted). A pr efix r eversal β = β (1 , j ) for some 3 ≤ j ≤ n + 1 applied to π rev er ses the elements π 1 , . . . , π j − 1 and thus tr ansforms π int o p ermutation π · β = [ π 0 , π j − 1 , . . . , π 1 , π j , . . . , π n +1 ]. A pr efix tr ansp osition τ = τ (1 , j, k ) fo r some 2 ≤ j ≤ n and s ome 3 ≤ k ≤ n + 1 such that k / ∈ [1 , j ] cuts the elements π 1 , . . . , π j − 1 and pa stes betw een π k − 1 and π k and thus transforms π into p e rmutation π · τ = [ π 0 , π j , . . . , π k − 1 , π 1 , . . . , π j − 1 , π k , . . . , π n +1 ]. An identity p ermutation ι n is a p er m utatio n such that π i = i for all 1 ≤ i ≤ n . Given tw o per mut a tio ns, the problem of sorting o ne p ermutation to another is equiv alen t to the problem of sorting a given p ermutation to the identit y p ermutation. The pr efix r eversal and pr efix tr ansp osition distanc e d ( π ) be t ween π and ι is the minim um num b er of op erations such that π · o 1 · o 2 · . . . · o d ( π ) = ι , w he r e each op eratio n o i is either a prefix reversal β or a prefix transp o s ition τ . The problem of sorting by pr efix r eversals and pr efix tr ansp ositions is, g iven a p ermutation π , to find a s hortest seq ue nc e of prefix r e versals and prefix tr ansp ositions such that per mut a tio n π transforms into the ident ity p ermutation ι , i.e. finding the distance d ( π ). 2 A br e akp oint for this problem is a po sition i of a per m utation π s uch that | π i − π i − 1 | 6 = 1 , and 2 ≤ i ≤ n . By definition, p osition 1 (b eginning of the p er m utatio n) is alwa ys considered a breakp oint. Position n + 1 (end of the p ermutation) is consider ed a brea k po int w hen π n 6 = n . W e denote b y b ( π ) the num be r of break po in ts of permutation π . Therefore, b ( π ) ≥ 1 for any permutation π and the o nly permutations with exactly one breakp oint are the ide ntit y p ermutations ( π = ι n , for a ll n ). The br e akp oint gr aph G π of π is a n undirected mult i gra ph whose vertices ar e π i , for 0 ≤ i ≤ n + 1 , and edges a re of t wo types: gr ey and black . F or each 1 ≤ i ≤ n + 1, the vertices π i and π i − 1 are joined by a bla ck edge iff ther e is a break po in t betw een them, i.e., iff | π i − π i − 1 | 6 = 1. F or 0 ≤ j < i ≤ n + 1 and j 6 = i − 1, there is a g rey edge b etw een π i and π j iff | π i − π j | = 1. F or conv enience of illustratio n, in this pap er the vertices of G π are dr awn horizontally from left to right in the or der o f π 0 , π 1 , . . . , π n +1 , the black edge s a re drawn by hor iz o ntal lines, and the grey edges are dr awn by dotted arcs . 3 3-appro ximation algorithm for prefix rev ersals and prefix transp ositions 3.1 The low er bo und F or a p ermutation π a nd an op er ation o , denote △ ( π , o ) = b ( π ) − b ( π · o ) as the nu mber o f breakp oints that are r emov ed due to op eration o . F ollowing ar e s o me imp ortant obser v ations a b out breakp o ints. Lemma 1. △ ( π , β ) ≤ 1 . Lemma 2. △ ( π , τ ) ≤ 2 . F rom L e mma 1 and Lemma 2 an optimal algo r ithm for this problem c a n no t r emov e more than tw o breakp oints by a single o per ation. So, a lower b ound follows. Theorem 1. d ( π ) ≥ ⌊ b ( π ) 2 ⌋ . 3.2 The algorithm Our algor ithm works on considering different o rientations o f grey and black edges . Note that if a p ermutation is not sorted there must b e at least t wo gr ey edges in the breakp oint graph and each g rey edge will b e incident to t wo black edges. A gre y edge with its tw o adja c ent black edg es must b e of one of the four types as shown in Fig. 1. Lemma 3. L et ( π 1 , π j ) b e a T yp e 1 gr ey e dge. Then t her e exists at le ast one black e dge ( π i − 1 , π i ) for some 2 ≤ i ≤ j . Pr o of. If no such bla ck edge e x ists, then s ubs e quence π 1 π 2 . . . π j is sorted. But in that case ( π 1 , π j ) would not b e a grey edge. ⊓ ⊔ W e ca ll such a black edge a tr app e d black e dge . In our a lgorithm we s c an the per mu tatio n from left to right to find the firs t black edg e incident to a gr ey edge. There are four p ossible scena r ios for the fo ur t yp es of edges. W e cons ider the s cenarios in the order as presented b elow in Fig. 1 and a pply a prefix transp osition or a pr efix reversal acco rdingly . Lemma 4. Given a p ermutation π and its asso ciate d br e akp oint gr aph G ( π ) , if any of the fol lowing two c onditions is satisfie d, then a pr efix r eversal or a pr efix tr ansp osition c an b e applie d to π such that it r emoves at le ast one br e akp oint. 1. G ( π ) c ontains a gr ey e dge ( π 1 , π j ) of T yp e 1 or T yp e 2 with π 1 6 = 1 . 2. G ( π ) c ontains a gr ey e dge ( π i , π j ) of T yp e 3 with π 1 = 1 . Pr o of. If π 1 6 = 1 and ther e is a grey edge ( π 1 , π j ) of Typ e 1, then Sce nario 1 is applicable: accor ding to Lemma 3, there exists a trapp ed black edg e ( π i − 1 , π i ) fo r so me 2 ≤ i ≤ j and we apply a prefix tr a nsp osition τ 1 (1 , i, j + 1) that crea tes a djacency b etw een π 1 and π j without intro ducing any new breakp oint. If on the other hand the grey edg e ( π 1 , π j ) is of Type 2, then Scenario 2 is applica ble: apply a pr efix reversal β 2 (1 , j ) that r e mov es a brea kp oint. If π 1 = 1 and the fir st gr ey edge is ( π i , π j ), then π 0 , π 1 . . . π i is so rted. If ( π i , π j ) is of Type 3, then a prefix tra nspo sition τ 3 (1 , i + 1 , j ) r emov es one br e a kp oint acc o rding to Scena rio 3. ⊓ ⊔ 3 Scenario 3 4 2 1 Edge Type τ 1 π 0 − π 1 . . . π i − π i +1 . . . π j − 1 − π j π 0 − π 1 . . . π i − 1 − π i . . . π j − π j +1 π 0 − π 1 . . . π i − 1 − π i . . . π j − 1 − π j π 0 − π i . . . π j π 1 . . . π i − 1 − π j +1 π 0 − π j − 1 . . . π 1 π j π 0 − π i +1 . . . π j − 1 − π 1 . . . π i π j β 2 τ 3 π 0 − π 1 . . . π j − 1 − π j π 0 − π j − 1 . . . π i − π i − 1 . . . π 1 − π j β 4 Fig. 1. Edge types and Scen arios of SortByR T3. Lemma 5. Given a p ermut ation π and its asso ciate d br e akp oint gr aph G ( π ) , if none of the Sc enario 1, 2 and 3 is applic able, then a pr efix r eversal c an b e applie d t hat do es not r emove any br e akp oint but is fol lowe d by two subse quent op er ations r emoving at le ast two br e akp oints. Pr o of. If scenar io 1 or 2 is not applicable, then π 1 = 1. Let π 1 , π 2 . . . π i − 1 , for some 1 < i < n , b e the larges t subsequence that is alre a dy so rted. Then there is a br eakp oint b etw een π i − 1 and π i . If the grey edge a djacent to π i − 1 is not of Type 3, then it m ust be of Type 4. Let the other endp oint o f the gr ey edg e be π j − 1 . So, we ca n apply , acco rding to Scenario 4 , a pr efix reversal β 4 (1 , j ) that do es not remov e an y br eakp oint but causes the gr ey edge to b ecome of Type 2. The n in the next step Scenario 2 w ill b e applicable with a pr efix reversal β 2 ( j − 1 , i − 1) that will remove o ne breakp oint. After applying β 2 , ( π 0 , π i ) w ill b ecome a breakp o int with i = 1 and π i 6 = 1. Hence, again, either Scenario 1 or Scena rio 2 will b e applicable, whic h will further remov e a breakp oint. So, a s a whole, we get t wo cons e cutive op eratio ns removing at least tw o br eakp oints after applying a r eversal tha t do es not r emov e a br eakp oint. ⊓ ⊔ Our algor ithm (SortByR T3 ) is summar iz ed in Algorithm 1. It clea rly r uns in po lynomial time. Algorithm 1 Sor tByR T3( π ) Construct breakp oint graph G π of π while th ere is a breakp oint do if π 1 6 = 1 then if S cenario 1 is applicable then apply a prefix transp osition τ 1 else i f Scenario 2 is applicable then apply a prefix reversal β 2 end if else if S cenario 3 is applicable then apply a prefix transp osition τ 3 else apply a prefix reversal β 4 end if end if end whil e 4 Theorem 2. SortByR T3 is a 3-app r oximation algorithm. Pr o of. By L e mma 4, if a ny of the Scena rio 1, 2 or 3 is applica ble, then the algorithm can remov e a t le a st one breakp oint at ea ch step. Otherwise a ccording to Lemma 5 it removes a t least tw o break po int s in thr ee steps. Hence, it s orts π in at most 3( b ( π ) − 1) 2 op erations. By Theorem 1, d ( π ) ≥ ⌊ b ( π ) 2 ⌋ . So, we get an approximation ratio o f ρ ≤ 3. ⊓ ⊔ 4 2-appro ximation algorithm Now we improv e the ratio consider ing a third r earra ngement op eration, called pr efix tr ansr eversal . A pr efix tr ansr eversal β τ = β τ (1 , j, k ) for some 2 ≤ j ≤ n and some 3 ≤ k ≤ n + 1 such that k / ∈ [1 , j ] reverses the elements π 1 , . . . , π j − 1 and then pastes it b etw een π k − 1 and π k and thus transforms π into p ermutation π · β τ = [ π 0 , π j , . . . , π k − 1 , π j − 1 , . . . , π 1 , π k , . . . , π n +1 ]. 4.1 The low er bo und Another imp ortant obse r v ation a b o ut breakp oints rega rding pr efix transr eversals is the following. Lemma 6. △ ( π , β τ ) ≤ 2 . F rom Lemma 1, Lemma 2 a nd L e mma 6 a low er b ound for sorting by pre fix reversals a nd prefix transr e- versals is the following. Theorem 3. d ( π ) ≥ ⌊ b ( π ) 2 ⌋ . 4.2 The algorithm The next lemma is the key to o ur 2-a pproximation. Lemma 7. L et π b e a p ermutation with π 1 = 1 and let its asso ciate d br e akp oi nt gr aph b e G ( π ) . If G ( π ) c ontains a gr ey e dge of T yp e 4, then a pr efix tr ansr eversal c an b e applie d that r emoves at le ast one br e akp oint. Pr o of. Let the T yp e 4 gr e y edge b e ( π i − 1 , π j − 1 ) with its tw o adjacent black edges ( π i − 1 , π i ) and ( π j − 1 , π j ). W e can apply a prefix transre versal β τ (1 , i , j ) creating a n adjacency b etw een π i − 1 and π j − 1 and thus removing a brea kpo int. ⊓ ⊔ The ab ove lemma along with Lemma 4 pr ov es that in every situa tion at least one br e a kp oint is remov ed by each op eratio n. Lemma 8. F or every p ermutation π , we have d ( π ) ≤ b ( π ) − 1 . Theorem 4. ⌊ b ( π ) 2 ⌋ ≤ d ( π ) ≤ b ( π ) − 1 . Theorem 5. An algorithm (let us c al l it SortByR T2) that pr o duc es pr efix re versals, pr efix tr ansp ositions, and/or pr efix tr ansr eversals ac c or ding to L emma 7 is an appr oximation algorithm with factor 2 for sorting by pr efix r eversals and pr efix tr ansr eversals. 5 3-appro ximation algorithm with forw ard march In this sec tio n w e introduce a new concept that we call forwar d mar ch . A t the very be g inning or a fter applying a pr e fix reversal or a pr e fix transp osition, a pre fix π 0 , . . . , π i , for 0 ≤ i ≤ n + 1 may be a lready sorted. In this case we upda te π as the unsorted suffix of π , i.e., as π = π i , . . . , π n +1 and the size of π is reduced by i , i.e ., the v alue of n is up dated as n = n − i . The nex t prefix reversal or prefix transp o s ition is applied o n up dated π . This co ncept of moving forward along with the sor ting is called forwar d mar ch . F or our algo rithm with forward march we redefine brea kp oint and break p o int gra ph. In the redefined br e akp oint gr aph G π of π ther e is a black edge b etw een π i and π i +1 iff there is a br eakp oint b etw een them, i.e., iff | π i − π i +1 | 6 = 1. Clear ly , π is sor ted iff it has no breakp oint. Note that a t a ny time π 0 is the last element in the sor ted pa r t o f the p ermutation and there always ex is ts a bla ck e dg e b etw een π 0 and π 1 . W e call this black edge the starting black e dge . 5 5.1 The low er bo und Due to brea k po int r edefinition some of our pre v ious obse r v ations ar e mo dified. Lemma 9. △ ( π , β ) ≤ 2 . Lemma 10. △ ( π , τ ) ≤ 3 . F rom Lemma 9 a nd Lemma 10 new low er b ound is the following. Theorem 6. d ( π ) ≥ b ( π ) 3 . 5.2 The algorithm Our algorithm works on consider ing different or ient a tions of grey a nd black edg es. If π is unsorted then it has at least tw o gre y edg es and at lea st one bla ck edg e in addition to the starting black edge ( π 0 , π 1 ). W e consider different o rientations of the four edge types o f Fig . 1 describ ed in Se c tion 3. W e try five scenarios in the or der shown in Fig. 2, apply a prefix tra nsp osition o r a pr efix reversal according ly and per form a forward march if pos s ible. In fact, Lemma 1 2 pr ov es that Scenario 4 and 5 a re sufficient to sort π , and Sce na rio 1, 2 a nd 3 improv e practical p erfor mance of our a lgorithm without affecting approximation ratio. O ur alg orithm (SortByR TwFM3) is summa rized in Algo rithm 2 . It clearly runs in p oly no mial time. β 5 π 0 π i . . . π j − 1 π 1 . . . π i − 1 π j π 0 π i . . . π j − 1 π 1 . . . π i − 1 π j π 0 π i . . . π j − 1 π j π 1 . . . π i − 1 π i . . . π j − 1 π 0 π j π 1 . . . π i − 1 π 0 π j − 1 π 1 . . . . . . π j π 0 π j − 1 . . . π 1 π j π 0 π 1 . . . π i − 1 π i . . . π j − 1 π j Scenari o 1 π 0 π 1 . . . π i − 1 π j π i . . .π j − 1 Scenari o 2 π 0 π j π i . . . π j − 1 π 1 . . .π i − 1 Scenari o 3 π 0 π j π i . . . π j − 1 π 1 . . . π i − 1 Scenari o 4 Scenari o 5 τ 1 τ 2 τ 3 τ 4 Fig. 2. Scenarios of S ortByR TwFM3 The following lemma is immediate from the scena r ios presented in Fig. 2. Lemma 11. After e ach pr efix rev ersal or pr efix tra nsp osition the numb er of br e akp oints is r e duc e d by at le ast one. The following lemma proves that our algorithm always terminates by so rting the p ermutation. Lemma 12. Sc enario 4 and Sc enario 5 ar e sufficient to sort the p ermu tation. 6 Algorithm 2 Sor tByR TwFM3( π ) Construct breakp oint graph G π of π while th ere is a blac k edge do if S cenario 1 is found then apply a prefix transp osition τ 1 else i f Scenario 2 is found then apply a prefix transp osition τ 2 else i f Scenario 3 is found then apply a prefix transp osition τ 3 else i f Scenario 4 is found then apply a prefix transp osition τ 4 else apply a prefix reversal β 5 end if G π ← G π after applying the op eration up date starting black edge to the first black edge of G π // F orward march end whil e Pr o of. Since π 1 6 = 1 , we alwa ys hav e a gr ey edge of Type 1 o r Type 2 whose left black e dge is ( π o , π 1 ). If the grey edge is o f Type 1, then b y Le mma 3 we can find a trapp ed black e dg e and can apply Sc e nario 4. O n the other hand, if the gr ey edg e is of T yp e 2, then Scenario 5 is applicable. B y Lemma 11 s inc e every scena rio reduces a t least one bre akp oint, Scenario 4 a nd Scenario 5 ca n successfully sort the p ermutation. ⊓ ⊔ Theorem 7. SortByR TwFM3 is a 3-appr oximation algorithm. Pr o of. By Lemma 12 our algor ithm success fully so rts a given p e rmutation π a nd by Lemma 11 it s o rts π in at most b ( π ) op erations . B y Lemma 6, d ( π ) ≥ b ( π ) 3 . So, we g et an approximation ratio of ρ ≤ 3. ⊓ ⊔ 6 Adaptiv e appro ximation ratios The alg orithms presented in this pap er r e alize their worst case a pproximation ratios as a result of combination of the b est cas e b ehavior of an optimal a lgorithm, w he r e no prefix reversal is applied, a nd a worst case behavior of our algo rithm, where no prefix tra nsp osition (or prefix tra nsreversal) is applied. This is due to the infer iority of prefix r eversals to prefix tr ansp ositions with r esp ect to their ability to remove breakp oints. How ever, it is exp ected that an optimal algor ithm would apply b oth o pe r ations. Motiv ated by the ab ove observ ation, we der ive adaptive approximation ratios for o ur a lgorithms in terms o f the num b er o f pr e fix reversals, r , applied by an optima l algo rithm. Although there is no change in the upp er bo und o f the algorithm, the approximation ratio will improve, b ecause of the increa sed low er b ound. Theorem 8. When r pr efix r eversals ar e applie d by an optimal algori thm, SortByR T3 sorts a p ermutation π with appr oximation r atio ρ r ≤ 3 − 3 r b ( π ) + r − 1 . Pr o of. F o r b ( π ) ≥ r , if an optimal algorithm uses r prefix r e versals, it remov es at mo s t r brea kp o ints (b y Lemma 1). F o r the r emaining ( b ( π ) − 1) − r breakp o ints it must use a t leas t ⌊ b ( π ) − r 2 ⌋ op erations (b y Theorem 1 ). As a r esult, d ( π ) ≥ r + ⌊ b ( π ) − r 2 ⌋ ≥ r + b ( π ) − 1 − r 2 = b ( π ) − 1 2 + r 2 Therefore, ρ r ≤ 3( b ( π ) − 1) 2 b ( π )+ r − 1 2 = 3( b ( π ) − 1) b ( π ) + r − 1 = 3 − 3 r b ( π ) + r − 1 ⊓ ⊔ Theorem 9. When r pr efix r eversals ar e applie d by an optimal algori thm, SortByR T2 sorts a p ermutation π with appr oximation r atio ρ r ≤ 2 − 2 r b ( π ) + r − 1 . Pr o of. An optimal algor ithm removes at most r brea kp o ints by r prefix reversals (by Lemma 1 ). F or the remaining ( b ( π ) − 1 − r ) br e a kp oints it must use at least ⌊ b ( π ) − r 2 ⌋ o per ations (by Theorem 3). As a r esult, d ( π ) ≥ r + ⌊ b ( π ) − r 2 ⌋ ≥ r + b ( π ) − 1 − r 2 = b ( π ) − 1 2 + r 2 Therefore, ρ r ≤ b ( π ) − 1 b ( π )+ r − 1 2 = 2 b ( π ) − 2+2 r − 2 r b ( π ) + r − 1 = 2 − 2 r b ( π ) + r − 1 ⊓ ⊔ 7 Theorem 10. When r pr efix re versals ar e p erforme d by an optimal algorithm, SortByR TwFM3 sorts a p ermutation π with appr oximation r atio ρ r ≤ 3 − 3 r b ( π ) + r . Pr o of. F o r b ( π ) ≥ 2 r an o ptimal a lg orithm applies r prefix reversals to remov e at most 2 r breakp oints (by Lemma 9). F or the r emaining b ( π ) − 2 r breakp oints it must use at least bπ − 2 r 3 op erations (by Theor e m 6). Therefore, d ( π ) ≥ r + b ( π ) − 2 r 3 = b ( π ) 3 + r 3 So, ρ r ≤ b ( π ) b ( π )+ r 3 = 3 b ( π ) +3 r − 3 r b ( π ) + r = 3 − 3 r b ( π ) + r ⊓ ⊔ 7 Exp erimen tal Results W e hav e implemen ted our algor ithms and tested their av erage p erfor mance on above 60,00 0 p ermutations taken randomly of s iz e up to 30 00. In each case the cost of solution given by prop ose d algor ithm is compared to co rresp onding lower b o und instead of compar ing with the cost of optimal solution. F or b oth SortByR T3 (Theorem 2) and So rtByR TwFM3 (Theor em 7) worst cases o ccur very few times in practice and shows r atio near 2 in average (Fig. 3 (a) a nd (e) resp ectively). F o r So rtByR T2 (Theor em 5) the practical r atio is no better tha n the theore tica l one due to its strateg y of c ho o sing sc e narios most of the time which r emov e only 1 brea kpo int in one op er ation (Fig. 3(c)). The ultimate effect of inducing inferior op erations (Theo r em 8, 9 and 1 0) is the increa s e of low er b ounds and thereby the decrea se of approximation ra tios. This is reflected in Fig. 3(b), (d) and (f ), res pe c tively , as the corr esp onding theoretical a nd pra c tical curves decrease and b ecome c lo ser to the o ptimal with the increase of r . Observe that if we co uld compare our algo rithms with corresp o nding optimal algorithms, then the ex- per imental r a tios would b e b etter. 8 Conclusion In this pap e r we have studied some v aria tions of the pa ncake flipping problem fro m the view p oint of sorting unsigned p ermutations. W e hav e given a 3-appr oximation a lgorithm for so rting b y prefix reversals and pre fix tra ns po sitions. Then we considered a third op eratio n, called prefix tr ansreversal, and provided a 3-approximation alg o rithm. W e also in tro duced a new concept ca lled forward march where we sk ip ov er the sorted prefix o f the p ermutation a nd a pply o pe r ations on some pr efix of the unsorted suffix of the per mut a tio n and contributed a 3-approximation a lgorithm. W e have further analyzed the problems in more practical wa y and pr esented b etter a pproximation r atios when a certain num ber o f inferio r o p e rations (i.e., prefix reversals) are applied by an optima l a lgorithm. An exper iment a l study s hows that o ur alg orithms per forms muc h b etter in practice than suggested by their a pproximation r atios. It will b e interesting to redefine the problems to “ force” certain num b er of inferio r op erations and ana lyze the approximation ratios o f the algo rithms. This idea can be a pplied for other combination of more than one op eratio n. The complexity o f the problems ar e also unknown. In future it would be interesting to see whether the problems are NP- hard. References 1. Dwei ghter, H. A m erican Mathematical Monthly 82(1975), 1010 2. Bass, D.W., Sudb orough, I.H .: Pancak e problems with restricted prefix reversals and some correspond ing cayley netw orks. Journal of Pa rallel and Distributed Computing arc hive 63 (3) (March 2003) 327–336 3. Hannenhalli, S., Pevzner, P .: T ransfo rming cabb age in to turnip. In : Pro c. of 27th An nual ACM Symp osium on Theory of Computing (STOC’95). (1995) 178–18 9 4. Heydari, M.H., Sudb orough, I.H .: On sorting by prefix reversals and the diameter of pancake netw orks. P arallel Architectures and Their Efficient Use 678 (1993) 218–227 5. Heydari, M.H., Sudb orough, I.H .: On the diameter of the pancake netw ork. Journal of A lgorithms 25 (1) (1997) 67–94 6. Kececioglu, J., Sankoff, D.: Exact and ap p ro ximation algorithms for th e inv ersion distance b etw een tw o p er- mutatio n s. In: Pro c. of 4th Annual Sym p osium on Com binatorial Pattern Matc h in g, (CPM’93). V olume 684 of Lecture Notes in Comput er Science., S p ringer (1993) 87–105 Extended version has app eared in Algorithmic a , 13:180-21 0, 1995. 8 0 500 1000 1500 2000 2500 3000 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 permutation length, n number of operations/lower bound (a) SortByR T3 0 100 200 300 400 500 600 700 0.5 1 1.5 2 2.5 3 number of forced prefix reversals, r for fixed permutation length, 2500 adaptive approximation ratio, ρ r theoretical adaptive ratio practical adaptive ratio (b) Ad aptive SortByR T3 0 500 1000 1500 2000 2500 3000 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 permutation length, n number of operations/lower bound (c) SortByR T2 0 500 1000 1500 2000 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 number of forced prefix reversals, r for fixed permutation length, 2500 adaptive approximation ratio, ρ r theoretical adaptive ratio practical adaptive ratio (d) Ad aptive SortByR T2 0 500 1000 1500 2000 2500 3000 0.8 1 1.2 1.4 1.6 1.8 2 2.2 permutation length, n number of operations/lower bound (e) SortByR TwFM3 0 500 1000 1500 2000 2500 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3 number of forced prefix reversals, r for fixed permutation length, 2500 adaptive approximation ratio, ρ r theoretical adaptive ratio practical adaptive ratio (f ) Adaptive SortByR TwFM 3 Fig. 3. Exp erimental results 9 7. Bafna, V., Pevzner, P .: Genome rearrangemen ts and sorting by reversa ls. In: Pro c. of 34th An nual IEEE Sym- p osium on F oundations of Computer Science (FOCS’93). (1993) 148–157 A lso in SIAM Journal on Computing , 25:272-28 9, 1996. 8. Berman, P ., Hannenh alli, S ., Karpinski, M.: 1.375-approximation algo rithm for sorting by reversal s. In: Pro c. of 10th Europ ean S y mp osium on Algorithms (ESA’02). V olume 2461 of Lecture N otes in Computer Science., Springer (2002) 200–210 9. Christie, D.A .: Sorting permutations by block-interc hanges. Information Pro cessing Letters 60 (4) (1996) 165–169 10. Bafna, V., Pevzner, P .: Sorting p ermutations by transp ositions. In: Pro c. of the 6th A nnual ACM-SIAM Sym- p osium on D iscrete Algorithms (SODA’95). (1995) 614–623 Also in SI AM Journal on Discr ete Mathematics , 11(2):224-24 0, 1998. 11. Elias, I ., Hartman, T.: A 1.375-appro x imation algori th m for sorting by transp ositions. In: Proc. of 5th Inter- national W orkshop on Algorithms in Bioinformatics (W ABI’05). V olume 3692 of Lecture Notes in Computer Science., Sp ringer (O ctob er 2005) 204–214 12. Hartman, T.: A simpler 1.5-approximation algorithm for sorting by tran sp ositions. In: Proc. of 14th Annual Symp osium on Com binatorial Pa ttern Matc hin g (CPM’03). V olume 2676 of Lecture Notes in Computer Science., Springer (2003) 156–169 13. Hartman, T., Sharan, R.: A 1.5-approximation algo rithm for sorting by transp ositions and transreversal s. In: Proc. of 4th International W orkshop on Algorithms in Bioinformatics (W ABI’04 ). V olume 3240 of Lecture Notes in Computer Science., Springer (2004) 50–61 14. Lu, C.L., Huang, Y.L., W ang, T.C., Chiu, H.T.: Analysis of circular genome rearrangement by fusions, fissions and blo ck-interc hanges. BMC Bioinformatics (12 June 2006) 15. Dias, Z., Meidanis, J.: Sorting by prefi x t ransp ositions. In: 9th I nternational Symp osium on String Processing and Information Retrieva l (SPIRE 2002). V olume 2476 of Lecture N otes in Computer Science., Sp ringer (2002) 463–468 16. Caprara, A.: Sorting by reversa ls is difficult. In: Pro c. of 1st ACM Conference on Researc h in Computational Molecular Biology (RECOMB’97). (1997) 75–83 17. Heydari, M.H., S udb orough, I.H .: Sorting by prefix reversals is np- complete T o b e submitted (as mentioned in [18]). 18. W alter, M., Dias, Z., Meidanis, J.: Reversal and transp osition d istance of linear chromo somes. In : South A merican Symp osium on String Pro cessing and Information Retriev al (SPIR E’98), I EEE Computer So ciety (1998) 96–102 19. Gu, Q., Peng, S., Sud b orough, H.: A 2-appro x imation algorithm for genome rearrangemen ts by reversals and transp ositions. Theoritical Comput er S cience 210 (2) (1999) 327–339 20. Lin, G., Xue, G.: Signed genome rearrangemen ts b y rev ersals and transpositions: Models and appro x imations. In: Pro c. of 5th Annual International Conference on Computing and Com binatorics (COCOON’99). V olume 1627 of Lecture Notes in Comput er Science., Sp ringer (1999) 71–80 21. Eriksen, N .: (1+ ǫ )-approximation of sorting by reversals and transpositions. Theoretical Comput er Science 289 (1) (2002) 517–529 22. Rahman, A., Shatab da, S., Hasan, M.: An app o x imation algorithm for sorting by reversals and transp ositions. Journal of Discrete Algorithms 6 (3) (2008) 449–457 23. Lou, X., Zhu, D.: A 2.25-approximation algorithm for cut-and- paste sorting of unsigned circular p ermutatio ns. In: COCOON. (2008) 331–341 10
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment