UPB Sci Bull, Series A, Vol 7, Iss, ISSN 3-77 A METHOD TO COMPARE TWO COMPLEXITY FUNCTIONS USING COMPLEXITY CLASSES Adrei-Horia MOGOS, Adia Magda FLOREA Complexitatea uui algoritm poate i exprimată ca o ucţie, umită ucţie de complexitate I acest articol studiem compararea a două ucţii de complexitate olosid clase de complexitate Dupa ce deiim multimea tuturor ucţiilor de complexitate comparabile cu o ucţie dată, prezetăm câteva proprietăţi ale acestei mulţimi Cele mai importate rezultate di articolul ostru sut cateva criterii suiciete petru ca două ucţii de complexitate să ie comparabile şi câteva criterii suiciete petru ca două ucţii de complexitate să ie icomparabile The complexity o a algorithm ca be expressed as a uctio, called complexity uctio I this paper we study the compariso o two complexity uctios usig complexity classes Ater deiig the set o all complexity uctios comparable with a give uctio, we give some properties o this set The most importat results o our paper are some suiciet criteria or two complexity uctios to be comparable ad some suiciet criteria or two complexity uctios to be icomparable Keywords: algorithm, complexity uctio, complexity class, complexity uctios compariso Itroductio Complexity uctios are used i various research ields For example, i [] complexity uctios describe some properties o the dyamic systems, ad i [] complexity uctios describe the complexity o the structure o models related to some techical systems I this paper, complexity uctios are used or measurig the complexity o algorithms The complexity o a algorithm ca be expressed usig a complexity uctio, ie, a positive real valued uctio deied o the set o positive itegers I may cases such uctios have complicated expressios ad usig these uctios is a diicult task For this reaso, computer scietists ote express the complexity o a algorithm usig complexity classes, a simpler way o expressig the complexity o a algorithm, but a less exact oe Some basic Assistat, Departmet o Computer Sciece, Uiversity POLITEHNICA o Bucharest, Romaia, e-mail: mogosadrei@yahoocom Proessor, Departmet o Computer Sciece, Uiversity POLITEHNICA o Bucharest, Romaia, e-mail: adiamagdalorea@yahoocom
7 Adrei-Horia Mogos, Adia Magda Florea properties o the complexity classes are preseted i almost ay paper or book that cotais some elemets o algorithms complexity theory See, or example [3], [4], [5] I this paper we study the complexity uctios usig the elemetary theory o uctios ad sets Other approaches use more advaced mathematical theories: or example, i [6], the authors use the osymmetric Hausdor distace or studyig the complexity uctios; i [7] the authors itroduce a ew quasi-metric o the dual p-complexity space or studyig the complexity distaces betwee algorithms Nevertheless, our approach is powerul eough to help us to obtai several iterestig results As oe ca observe, whe comparig algorithms, i act we compare complexity uctios, or at least complexity classes A possible use case o algorithms compariso is whe someoe wats to develop a very eiciet algorithm or solvig a give problem, see or example [8] Aother use case is whe someoe is iterested i complexity aalysis i heterogeeous systems, see or example [9] A iterestig idea is preseted i [4]: the authors oly draw a aalogy betwee the compariso o the complexity uctios usig complexity classes ad the compariso o real umbers Their immediate coclusio was that every two real umbers ca be compared, but ot every two complexity uctios ca be compared Startig rom the results preseted i [], [], this paper studies the compariso o two complexity uctios usig complexity classes Ater we deie the set o all complexity uctios comparable with a give uctio, we give some properties o this set We also preset some iterestig properties o the complexity classes The mai cotributios o this paper are some suiciet criteria or two complexity uctios to be comparable ad some suiciet criteria or two complexity uctios to be icomparable The paper is orgaized as ollows Sectio cotais the deiitios used or the rest o the paper Sectio 3 presets some properties o the complexity classes Sectio 4 cotais the mai results o our paper Fially, i Sectio 5, we preset the coclusios o the paper Deiitios We will deote by R the set o all positive real umbers ad by N the set o all positive itegers We will cosider the uctio g : N R to be a arbitrary ixed complexity uctio Cosider the ollowig complexity classes (see [4], [5]):
A method to compare two complexity uctios usig complexity classes 7 ( = { : N c, c Θ R, R, } N () O( = { : N R c R,, } Ω ( = { : N R c R,, } o( = { : N R c R, <, } ω( = { : N R c R, <, } () (3) (4) (5) Deiitio Let : N R be a complexity uctio The uctio ( is comparable with the uctio g ( i O( Ω( o( (6) We say that the uctio ( is icomparable with the uctio g ( i ( is ot comparable with g ( We deote by C ( the set o all the complexity uctios comparable with the uctio g ( Remark We have the ollowig idetity: C( = Θ( O( Ω( o( (7) Deiitio We deie the ollowig complexity classes: oθ ( = O( \ ( o( ) (8) Θ ω( = Ω( \ ( Θ( ) (9) 3 Some properties o the complexity classes This sectio shows some properties o the complexity classes deied i the previous sectio
7 Adrei-Horia Mogos, Adia Magda Florea Propositio We have the ollowig properties: a) Θ ( g ( Ø, O ( Ø, Ω ( g ( Ø b) o ( Ø, ω ( Ø c) o Θ ( Ø, Θ ω ( Ø Proo a) These results ollow rom the ollowig observatios:,, () b) It ca be proved, usig (4) ad (5), that / ad ω( c) Let us show that o Θ ( Ø Cosider two complexity uctios: ( ( We deie the ollowig complexity uctio: : N (, = k = (, = R, k () The uctio ( is deied by ( ) or odd umber, ad by ( ) or eve umber Next, we prove that We have to show that,, ad From )) we have: c, c R,, () From )) we have: c R, ( <, (3) From the deiitio o ( it ollows that c, c R,,, = k (4)
A method to compare two complexity uctios usig complexity classes 73 c R, <,, = k (5) ad cosequetly c R,, c R,, = k,, = k (6) (7) Let be c = max{ c, c } ad let be max{, = } It ollows that, (8) so we have Next, we assume that We have: c, c R, such that, (9) From the deiitio o ( we have c R, <,, = k () Let be = max{, } For c = c we have, ad < c,, = k () Cosequetly Usig the same idea, it ca be proved that So, we have,, ad It ollows that \ ( o( ) that is For provig that Θ ω( Ø oe ca use a similar idea
74 Adrei-Horia Mogos, Adia Magda Florea Propositio We have the ollowig properties: a) o( ω( = Ø, O( Ω( = Θ( b) o( Ω( = Ø, O( ω( = Ø c) o( O(, Θ ( O( d) ω ( Ω(, Θ ( Ω( Proo The results ca be obtaied usig (), (), (3), (4), ad (5) Propositio 3We have the ollowig properties: a) o( Θ( = Ø, o( oθ( = Ø, oθ ( Θ( = Ø b) o ( oθ( = O( I other words, the complexity classes o (, oθ ( ad Θ ( orm a partitio o the complexity class O ( Proo a) The irst equality ca be obtaied usig the deiitios () ad (4) The other two equalities are easily obtaied rom the deiitio o the complexity class oθ ( b) From Propositio 3, we have o( O( Usig the deiitio o oθ ( we have o ( oθ( = O( Propositio 4 We have the ollowig properties: a) Θ ( ω( = Ø, Θ ( Θω( = Ø, Θ ω( ω( = Ø b) Θ( Θω ( = Ω( I other words, the complexity classes Θ (, Θ ω( ad ω ( orm a partitio o the complexity class Ω ( Proo The proo ollows the same idea as the proo or Propositio 4 Propositio 5 Let be N ad N two iiite subsets o N, N ad N orm a partitio o N Let be ( ) ad two complexity uctios Let be (, = () (, The, we have: a) I ( ( the b) I ( ( the c) I )) ad )) the
A method to compare two complexity uctios usig complexity classes 75 d) I ( ( the e) I ( ( the Proo For provig these results, we use the deiitios rom (), (), (3), (4), ad (5) a) From (, (, rom the expressio o ( we have: c, c R, such that,, (3) c, c R, such that,, (4) Let be c = mi( c, ), c = max( c, ), ad = max(, ) The, we have: c c,,,, (5) It ollows that b), c), d), e) The proos use the same idea as the proo or a) Propositio 6 Let be N ad N two iiite subsets o N, N ad N orm a partitio o N Let be ( ) ad two complexity uctios Let be (, = (6) (, The, we have: a) I ( ( the b) I ( ( O( the O( c) I ( ( Ω( the Ω( d) I ( ( the e) I )) ad ω( )) the ω(
76 Adrei-Horia Mogos, Adia Magda Florea Proo For provig these results, we use the deiitios rom (), (), (3), (4), ad (5) a) From )) we have that the property c, c R, such that,, (7) is alse I ollows that the property c, c R, such that,, (8) is alse Sice N is a iiite subset o N, we have b), c), d), e) The proos use the same idea as the proo or a) Propositio 7 Let be N ad N two iiite subsets o N, N ad N orm a partitio o N Let be ( ) ad two complexity uctios Let be (, = (9) (, The, we have: a) I ( ( the b) I ( ( the Proo For provig these results we use Propositio 5, Propositio 6, ad the properties: o ( Θ( = Ø ad Θ ( ω ( = Ø a) From ( ( we have ( ( Cosequetly, From ( ( we have ( ( Cosequetly, From ( ( we have ( ( Cosequetly, It ollows that \ ( o( ) Cosequetly, b) The proo uses the same idea as the proo or a)
A method to compare two complexity uctios usig complexity classes 77 Propositio 8 We have the ollowig property: i ad oly i ( Proo We have the ollowig well kow properties: i ad oly i ( (3) i ad oly i ( (3) i ad oly i ω( ( (3) From Deiitio, we have: oθ ( = O( \ ( o( ) (33) Θ ω( = Ω( \ ( Θ( ) (34) Cosider that We show that ( From the deiitio o oθ ( we have so, we have \ ( o( ) (35),, (36) Usig (3), (3), (3) it ollows that (, ω( (, ( Cosequetly, ( \ ( Θ( ( ( ) It ollows that ( The other implicatio ca be proved usig the same idea Propositio 9 Let be N ad N two iiite subsets o N, N ad N orm a partitio o N Let be ( ( two complexity uctios Let be (, = (37) (,
78 Adrei-Horia Mogos, Adia Magda Florea The, we have: a) I ( ( the b) I ( ( the c) I ( ( the d) I ( ( the Proo a) From ( we have that (, (, ( From ( we have that (, (, ( Cosequetly, usig Propositio 5 ad Propositio 6, we have,, ad It ollows that b), c), d) The proos use the same idea as the proo or a) 4 The mai results Theorem Let be The ( Proo We will use a well kow property o the complexity classes: ( i ad oly i ( )) (38) ( The hypothesis implies that Ω( From Propositio, we have O( Ω( = Θ( It ollows that we have two possibilities: either or ( Ω( \ Θ( ) I the (, hece ( I ( Ω( \ Θ( ) Ω( the (, hece ( Theorem The complexity classes o (, oθ (, Θ (, Θ ω( ad ω ( orm a partitio o the set C (, that is: a) C( = o( oθ( Θω( b) The complexity classes o (, oθ (, Θ (, Θ ω( ad ω ( are pairwise disjoit Proo a) For provig this result we use Remark, Propositio 3, ad Propositio 4 From C( = Θ( O( Ω( o( ω( (39)
A method to compare two complexity uctios usig complexity classes 79 we have C( = Θ( o( oθ( Θω( o( ω( (4) It ollows that C( = o( oθ( Θω( ω( (4) b) From Propositio 3, it ollows that o (, oθ( ad Θ ( are pairwise disjoit From Propositio 4, i ollows that Θ (, Θ ω( ad ω ( are pairwise disjoit From Propositio, i ollows that o ( ad ω ( are disjoit Usig Propositio, we have that o( Ω( = Ø, hece o ( ad Θ ω( are disjoit Usig agai Propositio, have O( ω( = Ø, hece oθ ( ad ω ( are disjoit From Propositio we have that O( Ω( = Θ( We kow that oθ ( O( ad Θω ( Ω( We also kow that oθ ( ad Θ ( are disjoit ad Θ ( ad Θω( are disjoit It ollows that oθ ( ad Θ ω( are disjoit Cosequetly o (, oθ (, Θ (, Θ ω( ad ω ( are pairwise disjoit Theorem 3 Let be ( ( two complexity uctios The ( ( ( ( Proo From )), we have: c R, ( <, From )), we have: (4) c R, < (, (43) Let be c R ; or c = c = c there exist ad with the above properties Let be = max{, } The, we have:
8 Adrei-Horia Mogos, Adia Magda Florea that is: It ollows that: ( < (44) ad < (, ( < (45) < (, c = R, = ( (, (46) hece ( ( From here, we have ( ( Next, usig Theorem, it ollows that ( )) ( Remark 3 I C( we say that ( ad g ( are comparable Note that, rom Theorem, i the ( Theorem 4We have the ollowig properties: a) Let be ( ( The ( ( b) Let be ( ( The ( ( Proo We prove that i ( ( the ( )) From )) ad Ω( )) we have: ( c R, ( <, (47) c R, (, (48) I we choose c = c, the we have: Next, we have <, max(, ) (49) c = R, = max(, ) < c (, such that (5) Cosequetly, ( )) It ollows that ( )) ( (
A method to compare two complexity uctios usig complexity classes 8 Usig Propositio 4, we have: Θ ( Ω( (5) Θω ( Ω( (5) a) From ( ( we have that ( ( It ollows that ( ( b) From ( ( we have that )) ad )) It ollows that ( )) ( Theorem 5 We have the ollowig properties: a) Let be ( ω( ( The ( ( b) Let be ( ( The ( ( Proo The proo ollows the same idea as the proo or the Theorem 4 Theorem 6 We have the ollowig properties: a) Let be ( ( The ( ( b) Let be ( ( The ( ( c) Let be ( ( The ( ( Proo Usig the same idea used i the proo o Theorem 4, oe ca prove that i ( ( the ( ( a) We have oθ ( O( ad Θ ( Ω( Cosequetly, we have ( ( It ollows that ( ( b), c) The proos ollow the same idea used or the proo o a) Theorem 7 We have the ollowig properties: a) There exists (, ( ( C( ( b) There exists (, ( ( C( ( Proo a) Let be /, = k = /, ( = (53), = k
8 Adrei-Horia Mogos, Adia Magda Florea It is easy to see that /, /, ad We have ( Usig Propositio 7, we have that ( Oe ca observe that ( / ) ( I additio, the set o odd aturals ad the set o eve aturals are iiite sets It ollows that ( C( ( b) The proo uses the same idea as the proo or a) Theorem 8 We have the ollowig properties: a) Let be ( ad g ( ) ω ( ( )) The ( ) ( ( C b) Let be ) o ( ( )) ad ( )) The ( ) ( ( C c) Let be ) o ( ( )) ad ( )) The ( ) ( ( C d) Let be g ( ) ω ( ( )) ad ( )) The ( ) ( ( C e) Let be g ( ) ω ( ( )) ad ( )) The ( ) ( ( C Proo We will use Propositio 8, ormulas (3), (3), (35), Theorem 3, Theorem 4, ad Theorem 5 a) From ( ad g ( ) ω ( ( )) we have that ( ( It ollows that ( ( b), c), d), e) The proos use the same idea as the proo or a) Theorem 9 Let be N ad N two iiite subsets o N, N ad N orm a partitio o N Let be ( ( two complexity uctios Let be (, = (54) (, The, we have: a) I ( ( the b) I ( ( the c) I ( ( the d) I ( ( the e) I ( ( the ) I ( ( the Proo For provig the theorem, we use Propositio 9 ad Propositio 5
A method to compare two complexity uctios usig complexity classes 83 a) From ( ( we have that Cosequetly, It ollows that c) From ( ( we have that ( ( Cosequetly, It ollows that b), d), e) The proos use the same idea as the proo or a) ) The proo uses the same idea as the proo or c) Theorem Let be N ad N two iiite subsets o N, N ad N orm a partitio o N Let be ( ) ad two complexity uctios Let be (, = (55) (, The, we have: a) I ( ( the C( b) I ( ( the C( c) I ( ( the C( d) I ( ( the C( Proo For provig that, we eed to id a complexity class that cotais both ( ) ( ) We will show that this is impossible Usig Remark, we have: C( = Θ( O( Ω( o( (56) The largest two complexity classes are O( ad Ω ( So we ca use the orm o C ( discussed i Remark : C( = O( Ω( a) From ( we have ( ( Ω( From ( we have ( O( ( It ollows that C( b), c), d) The proos use the same idea as the proo or a)
84 Adrei-Horia Mogos, Adia Magda Florea 6 Coclusio I this paper we preseted some iterestig results related to the compariso o two complexity uctios usig complexity classes These results are importat i practice because whe we compare two complexity uctios, i act, we compare two algorithms complexities Usig the results rom this paper, some algorithms ca be desiged to tell us i two uctios are comparable or to tell us i two uctios are icomparable Ackowledgemet This research was supported by the AGATE project: Sel-aware ad selorgaizig cogitive agets societies or modelig ad developig complex systems - Grat CNCSIS ID_35, 9- R E F E R E N C E S [] V Araimovich, L Glebsky, Measures Related to (ε, -Complexity Fuctios, i Discrete ad Cotiuous Dyamical Systems, vol, o &, Sept & Oct 8, pp 3-34 [] E Schmidt, A Schulz, L Kruse, G vo Cöll ad W Nebel, Automatic Geeratio o Complexity Fuctios or High-Level Power Aalysis, i Proceedigs o PATMOS, the Iteratioal Workshop Power ad Timig Modelig, Optimizatio ad Simulatio, Yverdo-les-bais, Switzerlad, 6-8 Sept, pp 6-35 [3] DE Kuth, Fudametal Algorithms, volume o The Art o Computer Programmig, Third editio, Addiso-Wesley, USA, 997 [4] TH Corme, CE Leiserso, RL Rivest ad C Stei, Itroductio to Algorithms, Secod editio, MIT Press, Cambridge Massachusetts, Lodo Eglad, USA, [5] CA Giumale, Itroducere i Aaliza Algoritmilor Teorie si aplicatie (Itroductio to the Aalysis o Algorithms Theory ad Applicatio, Polirom, Bucharest, Romaia, 4 [6] J Rodríguez-López, S Romaguera ad O Valero, Asymptotic Complexity o Algorithms via the Nosymmetric Hausdor Distace, i Computig Letters (CoLe), vol, o 3, 4, pp 55-6 [7] S Romaguera, E A Sáchez-Pérez ad O Valero, Computig Complexity Distaces Betwee Algorithms, i Kyberetika, vol 39, o 5, 3, pp 569-58 [8] M I Adreica, Eiciet Gaussia Elimiatio o a D SIMD Array o Processors without Colum Broadcasts, i U P B Sci Bull, series C, vol 7, Iss 4, 9, pp 83-98 [9] K Sharma, D Garg, Complexity Aalysis i Heterogeeous System, i Computer ad Iormatio Sciece, vol, o, Feb 9, pp 48-5 [] AH Mogos, Comparable Complexity Fuctios, i Proceedigs o CSCS 6, the 6 th Iteratioal Coerece o Cotrol Systems ad Computer Sciece, Bucharest, Romaia, -5 May 7, vol, pp 46-5 [] AH Mogos, AM Florea, Comparig Two Complexity Fuctios usig -Comparable Complexity Fuctios, i Proceedigs o CSCS 7, the 7 th Iteratioal Coerece o Cotrol Systems ad Computer Sciece, Bucharest, Romaia, 6-9 May 9, vol, pp 55-6