A Comparative Study on the Algorithms for a Generalized Josephus Problem

Size: px
Start display at page:

Download "A Comparative Study on the Algorithms for a Generalized Josephus Problem"

Transcription

1 Appl. Math. If. Sci. 7, No. 4, (2013) 1451 Applied Mathematics & Iformatio Scieces A Iteratioal Joural A Comparative Study o the Algorithms for a Geeralized Josephus Problem Lei Wag 1 ad Xiaog Wag 2,3, 1 Microsoft AdCeter, Bellevue, WA 98004, USA 2 Faculty of Mathematics ad Computer Sciece, Fuzhou Uiversity, Fuzhou, Chia 3 Faculty of Computer Sciece, Quazhou Normal Uiversity, Quazhou, Chia Received: 3 Dec. 2012, Revised: 14 Ja. 2013, Accepted: 12 Mar Published olie: 1 Jul Abstract: The classic Josephus problem ca be described as follows: There are objects, cosecutively umbered from 1 through, arraged i a circle. We are give a positive iteger k. Begiig with a desigated first object, we proceed aroud the circle, removig every kth object. After each object is removed, coutig cotiues aroud the circle that remais. This process cotiues util all objects have bee removed. I a geeralized Josephus problem, a umber of lives l is itroduced for the problem. Each object has l lives. The object is removed oly whe it has bee selected l times. I this paper we preset a fast algorithm for geeratig the Josephus permutatio for the geeralized Josephus problem. Our ew algorithm ca also be applied to a more geeral case of the geeralized Josephus problem where the lives for all objects ca be differet. The time ad space complexities of ew algorithms are O(llogk) ad O() respectively. The computatioal experimets demostrate that the achieved results are ot oly of theoretical iterest, but also that the techiques developed may actually lead to cosiderably faster algorithms. Keywords: Josephus permutatio, hit sequece, full biary tree 1. Itroductio I this paper we study a ew variat of the Josephus problem [1, 2, 3]. The classic Josephus problem is defied as follows. Suppose that objects, cosecutively umbered from 1 through, are arraged i a circle ad that we are give a positive iteger k. Begiig with a desigated first object, we proceed aroud the circle, removig every kth object. After each object is removed, coutig cotiues aroud the circle that remais. This process cotiues util all objects have bee removed. The order i which the objects are removed from the circle defies a particular permutatio of the itegers 1, 2,,. This permutatio is usually called the (, k) Josephus permutatio. For example, the (6,4) Josephus permutatio is ( ). There are also various geeralizatios o the classic Josephus problem i the literature [4, 6]. I a recet research [5], the classic Josephus problem was geeralized as follows. A uiform umber of lives l is itroduced for the problem. Each object has l lives. The object is removed oly whe it has bee selected for l times. This ew variat of Josephus problem was called Felie Josephus problem. I this geeralized Josephus problem, correspodig to the order i which the objects are removed from the circle, there is also a particular permutatio of the itegers 1,2,,. This permutatio is called the (, k, l) Josephus permutatio. For example, the (6,4,2) Josephus permutatio is ( ). The classic Josephus problem is a special case of the geeralized Josephus problem whe l = 1. We are iterested i algorithms which, give itegers, k ad l, geerate the correspodig (,k,l) Josephus permutatio. A O( 2 ) time algorithm usig O( 2 ) space to compute the last removed object of a give geeralized Josephus problem with objects is sketched i [5]. The time ad space complexities of the algorithm are idepedet of the problem parameters k ad l. The algorithm is coceptual feasible. Due to the O( 2 ) time ad space costs of the algorithm, the algorithm is oly of theoretical iterest. It is ot practical. I this paper we preset a practical algorithm for geeratig the geeral (, k, l) Josephus permutatio. Our Correspodig author wagxiaog@qztc.edu.c Natural Scieces Publishig Cor.

2 1452 L. Wag ad X. Wag: Algorithms for a Geeralized... ew algorithm ca also be applied to a more geeral case of the geeralized Josephus problem where the lives for all objects ca be differet. The time ad space complexities of the ew algorithm is O(llogk) ad O() respectively. Throughout the paper, we assume that a real RAM with a uiform cost criterio is the computatioal model. I particular, this meas that each arithmetic operatio requires costat time. The orgaizatio of the paper is as follows. I the followig 4 sectios we describe the algorithms ad our computatioal experiece with the algorithms for geeratig the geeral (, k, l) Josephus permutatio. I sectio 2 we describe a ew variat tree based algorithm for geeratig the hit sequeces of the geeralized Josephus problem ad their correctess ad complexities. Based o the algorithm i sectio 2, a improved algorithm for geeratig the (, k, l) Josephus permutatios is proposed i sectio 3. I sectio 4 we give a computatioal study of the preseted algorithms which demostrates that the achieved results are ot oly of theoretical iterest, but also that the techiques developed may actually lead to practical algorithms. Some cocludig remarks are i sectio A Fast Algorithm I this sectio we describe a fast algorithm for geeratig the (, k, l) Josephus permutatio. The algorithm is a variat of a tree based algorithm for classic Josephus problem proposed by Lloyd [3]. The ew variat of the algorithm uses a heap like data structure ad modified to solve the geeralized Josephus problem The Data Structures of the Algorithm The parameters to the geeralized Josephus problem are the umber of objects, the skip factor k, ad the umber of lives l. We make o assumptios about these parameters. I particular, k or l or both, could be larger tha. Whe the parameters are give, the followig otatios are itroduced for the geeralized Josephus problem i [5]. Let h i be the ith selected object. The sequece h 1,h 2,,h l is called the hit sequece. Let x i be the ith removed object. The sequece x 1,x 2,,x is called the kill sequece. It is obvious that the kill sequece forms the (, k, l) Josephus permutatio of (1, 2,, ). I the followig sectios, a object is called active before it is removed, ad dead after it is removed. For the give geeralized Josephus problem, there are objects ad the skip factor is k. I the followig sectios, we cosider a more geeral Josephus problem, where the umbers of lives for each object are ot ecessary cosistet. Assume at the begiig, the umber of lives for the ith object be l i,1 i. We use a array l to store the umber of lives for each object. Whe the ith object is selected, the correspodig value of l[i] is decreased by 1. If the value of l[i] becomes 0, the ith object is removed. Let m = 2 logk ad b = /m. The objects {1,,} are divided evely ito b groups as follows. {1,,m};{m+1,,2m}; ;{(b 1)m+1,,} Each group has m objects, except the last oe. For each group j,1 j b, we use a array a[ j 1] of size 2m 1 to store a full biary tree T j, with itegers i group j stored at its leaves a[ j 1][m 1],a[ j 1][m],,a[ j 1][2m 2]. All of the b full biary trees T j,1 j b costitute a two dimesioal array a. The ith active object i T j is the ith active iteger ecoutered i a left-to-right traversal of the leaves of T j. Also, a sequece of objects y 1,,y p is i leaf order with respect to the tree T j, if for 1 i p, y i is the ith active iteger i tree T j. Whe the object i a leaf is removed, the correspodig leaf is dead, otherwise it is a active leaf. The full biary tree T j is represeted as a array idexed biary tree a[ j 1]. For each ode a[ j 1][i],0 i m 2, its left child ode is a[ j 1][2 i + 1] ad its right child ode is a[ j 1][2 i+2]. For each ode a[ j 1][i], its paret ode is a[ j 1][ (i 1)/2 ]. Every ode of each tree a[ j 1] cotais a cout of the umber of active leaves i the subtree rooted at that ode. This is the size of the ode. Whe a object is removed, the size of each subtree cotaiig the object is decreased sice that object is ow dead. Notice that the meaigs of the values stored i the leaf odes ad the o-leaf odes of each tree T j are differet. It is obvious that the umber of active leaves i the subtree rooted at a leaf is 1 if the leaf is active, ad 0 if the leaf is dead. I order to distiguish the ode type of each tree T j, we chage the sig of iteger e stored i a leaf to e. Wheever we read a egative iteger e, we kow that it is a leaf ode represetig the object e. I additio, the trees are ubly liked together i a circular fashio, with tree T j liked after the tree T j 1 ad before the tree T j+1. Two arrays prev ad ext are used to represet the backward ad the forward liks respectively A Algorithm for Geeratig Hit Sequeces The algorithm cosists of two parts: the iitializatio procedure ad the mai program. I the iitializatio Natural Scieces Publishig Cor.

3 Appl. Math. If. Sci. 7, No. 4, (2013) / procedure, the data structure for the whole algorithm is iitialized as follows. Algorithm 2.1: INIT(, k, b, ext, prev) m 2 logk,b /m for i 0 to b 1 s i m,t (i+1) m for j 0 to m 1 u[ j] 0 for j s to mi(t 1, 1) u[ j s] ( j+ 1) BUILD(u, a[i]) t (i+1) mod b ext[i] t, prev[t] i I the algorithm described above, the sub-algorithm BUILD(u, v) is used to build the full biary tree v described i the last subsectio with its leaves give by the array u i the left-to-right order. A recursive fuctio COUNT(v,i) is used to cout the umber of active leaves i the subtree rooted at ode v[i] i a bottom-up fashio. A leaf ode with size 1 is recogized by the sig of its value. Algorithm 2.2: BUILD(u, v) procedure COUNT(v, i) if m<i+2 if v[i]<0 the the retur (1) else retur (0) v[i] COUNT(v,2 i+1) else v[i] v[i]+ COUNT(v,2 i+2) retur (v[i]) mai for i 0 to m 1 v[m+i 1] u[i] COUNT(v, 0) It is clear that the algorithm COUNT(v, i) requires O(m) = O(k) time ad so the algorithm COUNT(v,i) for each biary tree requires O(k) time. Thus, the iitializatio procedure requires O() total time. By the set of b trees represeted by the array a, the mai program to geerate the hit sequeces cosists of the followig: We will show later that the total cost of these operatios to geerate a hit object is O(logk). Whe two cosecutive trees become small, we the combie the two trees ito a ew tree of height logk. Such a combiig operatio is used to guaratee that the movemet betwee trees whe geeratig a hit object is limited to oe or two. By amortizig the cost of the operatios amog the dead objects i the two origial trees, we ca maitai the O(logk) cost for each hit object. Algorithm 2.3: ALGORITHM-L(, b) i 0,r 0,t b 1 while i< TREE(r, t) j LEAF(r,t) HIT(i, j,r,t) I the algorithm ALGORITHM-L(, b), three subalgorithms are called. The sub-algorithm TREE(r, t) is used to locate the tree cotaiig the ext active object to be hit. The sub-algorithm LEAF(r,t) is used to fid the ext active leaf to be hit. The sub-algorithm HIT(i, j,r,t) is used to output the ext hit object ad adjust the data structure. I these three sub-algorithms, the variable r plays a importat role. The variable r records the umber of active objects to the right of curretly hit leaf ode i the full biary tree cotaiig it. This variable is very useful to fid the positio of the ext hit object i our data structures. With the chagig of the hit sequeces, the variable r chages accordigly. The variable t is the idex of the full biary tree cotaiig the active leaf to be hit. Algorithm 2.4: TREE(r, t) if t = ext[t] ad r<k the{ r k+ a[t][0] 1 (k r 1) mod a[t][0] while r<k else t ext[t],r r+ a[t][0] Algorithm 2.5: LEAF(r, t) j 0,xt r k while j+ 1<m rs SIZE(a[t][2 j+ 2]) if r rs<k the j 2 j+ 2 else j 2 j+ 1,r r rs r xt retur ( j) I the algorithms above, the fuctio SIZE(a[t][ j]) returs the umber of active leaves i the subtree rooted at the ode a[t][ j]. Algorithm 2.6: HIT(i, j, r, t) h a[t][ j] output (h) if l[h 1]>1 the l[h 1] l[h 1] 1 else KILL(i, j,r,t) Natural Scieces Publishig Cor.

4 1454 L. Wag ad X. Wag: Algorithms for a Geeralized... The sub-algorithm KILL(i, j,r,t) is the heart of the whole algorithm which removes the dead leaf from the curret biary tree ad adjusts the curret data structures. Algorithm 2.7: KILL(i, j, r, t) a[t][ j] 0 while j> 0 j ( j 1)/2,a[t][ j] a[t][ j] 1 if t ext[t] if a[t][0]+a[ext[t]][0]=m { r r+ a[ext[t]][0] the COMBINE(t) the else if{ a[t][0]+a[prev[t]][0]=m t prev[t] the COMBINE(t) The algorithm COMBINE(t) will combie the two small trees a[t] ad a[ext[t]] ito a ew biary tree a[t], ad the tree a[ext[t]] will o loger be used. Algorithm 2.8: COMBINE(t) x ext[t],i 0 for j 0 { to m 1 if a[t][m+ j 1]<0 the u[i] a[t][m+ j 1],i i+1 for j 0 { to m 1 if a[x][m+ j 1]<0 the u[i] a[x][m+ j 1],i i+1 BUILD(u, a[t]) ext[t] ext[ext[t]], prev[ext[t]] t Now we cosider the time complexity for the whole algorithm. From the tests performed i the algorithm KILL(i, j, r, t), we kow that at the begiig of each executio of TREE(r, t), either there is exactly oe tree with active leaves, or for each tree a[t] with active leaves we have, a[t][0]+a[ext[t]][0] m k. It follows that there must be two trees with active leaves for the while-loop body of TREE(r, t) to be executed. Therefore, the while-loop body of each call of TREE(r,t) is executed at most twice. I the leaf search algorithm LEAF(r, t), the search follows a path from the root of the tree a[t] to a leaf a[t][ j]. Sice each tree created by the algorithm has a height of logk, the cost per iteratio of the while-loop i LEAF(r, t) is O(log k). Next we cosider the algorithm KILL(i, j, r, t). The time cost of the algorithm cosists of two parts. The first part is a series of ode value chages from the leaf a[t][ j] to the root a[t][0]. Sice the height of the tree is logk, the time of the first part is O(logk). The secod part of the time cost is icurred by the algorithm COMBINE(t). The cost of the algorithm is miated by the executio time of BUILD(u,a[t]) to build the ew full biary tree a[t]. We already kow the time cost for this task is O(k). This part of cost ca amortized to each leaf of the tree as follows. I the algorithm COMBINE(t), trees a[t] ad a[ext[t]] are combied. Whe these trees are created, each has m active leaves. Whe the algorithm COMBINE(t) is performed, these two trees have m active leaves ad m dead leaves. The O(m) cost of the algorithm ca thus be divided evely amog the objects stored at the m dead leaves. Each such object is thus assiged a cost of O(1). Sice each object is charged at most oce, the total cost of the algorithm COMBINE(t) performed i the whole algorithm is O(). Deote L= l i. Sice there are total L iteratios for the whole algorithm ad each iteratio requires O(log k) time. The time complexity of the whole algorithm is thus O(Llogk). The space used by the algorithm is obviously O(). Theorem 1 The algorithm ALGORITHM-L(, b) for solvig the geeralized Josephus problem requires O(L log k) time ad O() space. 3. A Improved Algorithm By explorig the followig property of the hit sequeces for a give geeralized Josephus problem, we ca improved the algorithm described i the last sectio further. A similar property was metioed i [5] with a iformal proof. The fact metioed there seems right, but the proof is ot strict ad icorrect. We will express this useful property by a theorem ad give a strict proof here. We divide the hit sequece ito segmets by the successively removed objects as follows r 1,r 2,,r. The segmet r i is called roud i hit sequece. The last object of r i is the ith removed object. Theorem 2 For each fixed idex i,1 i, the hit sequeces r i ca be uiquely formulated as r i = α s β, where s is a positive iteger, ad both of the sequeces α ad β are sequeces of uique elemets of {1,2,,}. Proof.We cosider the hit sequece r i for fixed idex i. There has bee i 1 objects removed before r i. The curret i + 1 objects remaied ca be writte i decreasig order by p 1, p 2,, p i+1. The positio p d is the startig positio where its predecessor x i 1 was just removed. The the ext object hit will be h 1 = p 1+(d+k 1) mod i+1. I geeral, suppose r i = t, ad for each 1 j t, d j = 1+(d+ jk 1) mod i+1, h j = p d j, the the hit sequece r i ca be writte as h 1,h 2,,h t. Natural Scieces Publishig Cor.

5 Appl. Math. If. Sci. 7, No. 4, (2013) / If all of the objects h 1,h 2,,h t are distict, the we kow the lives of the object h t must be 1, ad it is the ext removed object. This is the case of α = /0 ad β = {h 1,h 2,,h t }. Otherwise, the lives of each object i {h 1,h 2,,h t } must be greater tha 1. I this case, there must be a cycle i {h 1,h 2,,h t }. Suppose the cycle be {h u,h u+1,,h v }, 1 u v t. This meas that all of the objects h 1,h 2,,h v are distict, ad h v+1 = h u is the first object repeatedly hit. We ca show that u = 1, sice otherwise h u 1 = h v has bee hit repeatedly before h u. Therefore, we kow that {h 1,h 2,,h v } forms a cycle of the hit sequece. Suppose that l = mi{l[h j ] 1 j v}, ad j = mi{ j l[h j ] = l,1 j v}. It is readily see that h j will be the ext object to be removed. That is h j = h t. If we deote α = {h 1,h 2,,h v }, β = {h 1,h 2,,h j }, ad s = l 1, the the hit sequece r i ca be writte as r i = α s β. We ca easily see that s > 0, sice l > 1. I the special case of j = v, we have r i = α s+1. From Theorem 2, we kow that the lives of the curret objects ca be easily updated from the iformatio i determiig r i = α s β. First, if p j {h 1,h 2,,h t }, the the lives of p j remais uchaged. From the proof of Theorem 2 we kow that the last object of β is the removed object x i of roud r i. So, if p j β, the l[p j ] = l[p j ] s 1. If p j α ad p j β, the l[p j ]=l[p j ] s. Accordig to the Theorem 2, we ca improve the algorithm for solvig the geeralized Josephus problem to a ew algorithm ALGORITHM-N(,b) as follows. The sub-algorithm HIT(i, j, r, t) of the algorithm ALGORITHM-L(,b) is chaged to follows. Algorithm 3.1: HIT(i, j, r, t) h a[t][ j] q[g] h,g g+1 if g=1{ or l[h 1]<l[q[mi] 1] mi g 1 the p[0] t, p[1] j, p[2] r if l[q[mi] 1]=1 { or g>1 ad h=q[0] CHANGE(t, j,r,g,mi) the KILL(i, j,r,t) I the algorithm described above, we use a array q to record the hit sequece α of roud r i as stated i Theorem 2. A variable mi is used to record the idex of α with miimal lives. Whe a object with oly oe life is foud or a cycle of the hit sequece is foud, we the have determied r i = α s β. With the miimal lives i α recorded by mi, we ca easily update the lives of the curret objects accordig to Theorem 2 by algorithm CHANGE(t, j, r, g, mi) as follows. Algorithm 3.2: CHANGE(t, j, r, g, mi) d l[q[mi] 1] for i 0 to mi l[q[i] 1] l[q[i] 1] d for i mi+1 to g 2 l[q[i] 1] l[q[i] 1] d+ 1 g 0,t p[0], j p[1],r p[2] I the two sub-algorithms above, aother array p is used to record the iformatio t, j,r o the tree cotaiig the ext removed active object. Other parts of the algorithm ALGORITHM-L(, b) remais uchaged. Suppose for each hit sequece r i, the correspodig cyclic hit sequece stated i Theorem 2 be α i, ad the legth of α i be deoted as t i,1 i. Deote T = t i. Sice there are totally T iteratios for the whole modified algorithm ad each iteratio requires O(log k) time. The time complexity of the improved algorithm is thus O(T logk). The space used by the algorithm is obviously O(). Theorem 3 The improved algorithm ALGORITHM-N(, b) for solvig the geeralized Josephus problem requires O(T log k) time ad O() space. The modified algorithm is ideed a improvemet o the algorithm described i the last sectio, sice T = is much smaller tha L = t i l i. For example, if ad k are relatively prime, ad each object has a uiform umber of lives l, the the hit sequece will have the form α l 1 β, where α ad β are permutatios of {1,2,,} ad β is the Josephus permutatio for l = 1 [5]. So, i this case, the legth of α equals to, ad T = L = t i =, l i = l. The origial algorithm requires O(l logk) time, while the improved algorithm requires O(logk) time eve though the umber of lives l may ted to ifiite. 4. Computatioal Experimets I this sectio, we give some computatioal experimets o the performace of the algorithms for the geeralized Josephus problem. Natural Scieces Publishig Cor.

6 1456 L. Wag ad X. Wag: Algorithms for a Geeralized... Table 1: Comparig algorithms for small k ad l: Ruig times i secods k l Alg-R Alg-L Alg-N ***** ***** Table 2: Comparig algorithms for small l ad icreasig k: Ruig times i secods k l Alg-R Alg-L Alg-N Table 3: Comparig algorithms for ad k fixed ad icreasig l: Ruig times i secods k l Alg-R Alg-L Alg-N ***** ***** ***** ***** ***** Table 4: Comparig algorithms for fixed ad icreasig k ad l: Ruig times i secods k l Alg-R Alg-L Alg-N ***** ***** ***** ***** ***** Our computatioal experimets were carried out o a persoal computer with Petium(R) Dual Core CPU 2.10 GHz ad 2.0 Gb RAM. The word size of the processor is w=32. We compare the three algorithms, the O( 2 ) time algorithm i [5], deoted by ALGORITHM-R(), the algorithm ALGORITHM-L() described i sectio 2 ad the improved algorithm ALGORITHM-N() described i sectio 3 for 5 differet test data sets. I order to compare the algorithms with ALGORITHM-R(), the data sets are desiged with a uiform umber of lives for each test case. The ruig times i secods of the 3 algorithms for computig the geeralized Josephus permutatios with small parameters k ad l are compared i Table 1. The times reported for each value of idicate the results of ruig repeated 10 times to mitigate the effects of ram fluctuatios i system overhead. I the followig tables, the etries marked with symbol ***** could ot be solved due to isufficiet memory or time. As expected, i our experimets for small k ad l, the improved algorithm performs best with the umber of objects icreasig. For this data set the Algorithm-R exhibits a Ω( 2 ) time boud i the worst case. Table 2 gives the ruig times i secods of the 3 algorithms for computig the geeralized Josephus permutatios with small parameters l ad icreasig k. For this data set, the time costs of the 3 algorithms have oly small chages as the parameter k icreasig. Table 3 gives the ruig times i secods of the 3 algorithms for computig the geeralized Josephus permutatios with parameters ad k fixed ad icreasig l. As expected, i our experimets for icreasig l, the time cost of the algorithm ALGORITHM-L() is icreasig with the parameter l icreasig. While the algorithm ALGORITHM-R() ad the improved algorithm ALGORITHM-N() are ot affected by the icreasig of the parameter l. The improved algorithm ALGORITHM-N() performs best. For this data set the ALGORITHM-R() exhibits a Ω( 2 ) time boud too. Table 4 gives the ruig times i secods of the 3 algorithms for computig the geeralized Josephus permutatios with parameters fixed ad icreasig k ad l. The effect of icreasig k is ot sigificat for the 3 algorithms. Table 5 gives the ruig times i secods of the 3 algorithms for computig the geeralized Josephus permutatios with the 3 parameters,k ad l icreasig. As expected, for this data set, the improved algorithm performs best with the 3 parameters,k ad l icreasig. The algorithm ALGORITHM-L() is affected sigificatly by the parameter l ad ALGORITHM-R() exhibits a Ω( 2 ) time boud i the worst case. Natural Scieces Publishig Cor.

7 Appl. Math. If. Sci. 7, No. 4, (2013) / Table 5: Comparig algorithms for, k ad l icreasig: Ruig times i secods k l Alg-R Alg-L Alg-N ***** ***** Cocludig Remarks We have proposed a efficiet algorithm for computig the geeralized Josephus permutatios. The time cost of the ew algorithm is O(T logk) ad O() space is used. For some special cases of the geeralized Josephus problem, T = t i = O(). So our ew algorithm requires O( log k) time i these cases. This is a big improvemet o the previous algorithms. For the geeral Josephus problem, whether the formula T = t i = O() is always true is a ope problem. We will ivestigate the problem further. Lei Wag, PhD i Computer Sciece from Georgia Istitute of Techology Applied researcher at Microsoft. Has experiece i computer sciece with emphasis i algorithm desig. The areas of iterest are approximatio ad ramized algorithms,mechaism desig, market equilibrium computatio. Xiaog Wag, Professor i Computer Sciece Departmet of Quazhou Normal Uiversity ad Fuzhou Uiversity,Chia. Has experiece i computer sciece ad applied mathematics. The areas of iterest are desig ad aalysis of algorithms,expoetial-time algorithms for NP-hard problems,strategy game programmig. Ackowledgemet The authors ackowledge the fiacial support of Sciece ad Techology of Fegze uder Grat No.2009FZ24 ad 2010FZ02 ad the Haixi Project of Fujia uder Grat No.A099. The authors are grateful to the aoymous referee for a careful checkig of the details ad for helpful commets that improved this paper. Refereces [1] W.W. ROUSE BALL AND H.S.M. COXETER. Mathematical Recreatios ad Essays, Dover Publicatios (1987). [2] R.L. GRAHAM, D.E. KNUTH AND O. PATASHNIK. Cocrete Mathematics, Addiso Wesley (1994). [3] E.L. LLOYD. A O(logm) algorithm for the Josephus problem. Joural of Algorithms 4(3), (1983) [4] A. M. ODLYZKO AND H. S. WILF. Fuctioal Iteratio ad the Josephus Problem. Glasgow Math. J. 33, (1991) [5] F. RUSKEY AND A. WILLIAMS. The Felie Josephus Problem. Theory of Computig Systems, 50, (2012) [6] N. THERIAULT. Geeralizatios of the Josephus problem. Utilitas Mathamatica 58, (2000) Natural Scieces Publishig Cor.

Lecture 5. Counting Sort / Radix Sort

Lecture 5. Counting Sort / Radix Sort Lecture 5. Coutig Sort / Radix Sort T. H. Corme, C. E. Leiserso ad R. L. Rivest Itroductio to Algorithms, 3rd Editio, MIT Press, 2009 Sugkyukwa Uiversity Hyuseug Choo choo@skku.edu Copyright 2000-2018

More information

Sorting in Linear Time. Data Structures and Algorithms Andrei Bulatov

Sorting in Linear Time. Data Structures and Algorithms Andrei Bulatov Sortig i Liear Time Data Structures ad Algorithms Adrei Bulatov Algorithms Sortig i Liear Time 7-2 Compariso Sorts The oly test that all the algorithms we have cosidered so far is compariso The oly iformatio

More information

6.854J / J Advanced Algorithms Fall 2008

6.854J / J Advanced Algorithms Fall 2008 MIT OpeCourseWare http://ocw.mit.edu 6.854J / 18.415J Advaced Algorithms Fall 2008 For iformatio about citig these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advaced Algorithms

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

Chapter 24. Sorting. Objectives. 1. To study and analyze time efficiency of various sorting algorithms

Chapter 24. Sorting. Objectives. 1. To study and analyze time efficiency of various sorting algorithms Chapter 4 Sortig 1 Objectives 1. o study ad aalyze time efficiecy of various sortig algorithms 4. 4.7.. o desig, implemet, ad aalyze bubble sort 4.. 3. o desig, implemet, ad aalyze merge sort 4.3. 4. o

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

Sorting 9/15/2009. Sorting Problem. Insertion Sort: Soundness. Insertion Sort. Insertion Sort: Running Time. Insertion Sort: Soundness

Sorting 9/15/2009. Sorting Problem. Insertion Sort: Soundness. Insertion Sort. Insertion Sort: Running Time. Insertion Sort: Soundness 9/5/009 Algorithms Sortig 3- Sortig Sortig Problem The Sortig Problem Istace: A sequece of umbers Objective: A permutatio (reorderig) such that a ' K a' a, K,a a ', K, a' of the iput sequece The umbers

More information

why study sorting? Sorting is a classic subject in computer science. There are three reasons for studying sorting algorithms.

why study sorting? Sorting is a classic subject in computer science. There are three reasons for studying sorting algorithms. Chapter 5 Sortig IST311 - CIS65/506 Clevelad State Uiversity Prof. Victor Matos Adapted from: Itroductio to Java Programmig: Comprehesive Versio, Eighth Editio by Y. Daiel Liag why study sortig? Sortig

More information

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 201 Heaps 201 Goodrich ad Tamassia xkcd. http://xkcd.com/83/. Tree. Used with permissio uder

More information

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8)

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8) CIS 11 Data Structures ad Algorithms with Java Fall 017 Big-Oh Notatio Tuesday, September 5 (Make-up Friday, September 8) Learig Goals Review Big-Oh ad lear big/small omega/theta otatios Practice solvig

More information

Combination Labelings Of Graphs

Combination Labelings Of Graphs Applied Mathematics E-Notes, (0), - c ISSN 0-0 Available free at mirror sites of http://wwwmaththuedutw/ame/ Combiatio Labeligs Of Graphs Pak Chig Li y Received February 0 Abstract Suppose G = (V; E) is

More information

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015. Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Hash Tables xkcd. http://xkcd.com/221/. Radom Number. Used with permissio uder Creative

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

More information

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured

More information

Lower Bounds for Sorting

Lower Bounds for Sorting Liear Sortig Topics Covered: Lower Bouds for Sortig Coutig Sort Radix Sort Bucket Sort Lower Bouds for Sortig Compariso vs. o-compariso sortig Decisio tree model Worst case lower boud Compariso Sortig

More information

How do we evaluate algorithms?

How do we evaluate algorithms? F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:

More information

Counting the Number of Minimum Roman Dominating Functions of a Graph

Counting the Number of Minimum Roman Dominating Functions of a Graph Coutig the Number of Miimum Roma Domiatig Fuctios of a Graph SHI ZHENG ad KOH KHEE MENG, Natioal Uiversity of Sigapore We provide two algorithms coutig the umber of miimum Roma domiatig fuctios of a graph

More information

Sum-connectivity indices of trees and unicyclic graphs of fixed maximum degree

Sum-connectivity indices of trees and unicyclic graphs of fixed maximum degree 1 Sum-coectivity idices of trees ad uicyclic graphs of fixed maximum degree Zhibi Du a, Bo Zhou a *, Nead Triajstić b a Departmet of Mathematics, South Chia Normal Uiversity, uagzhou 510631, Chia email:

More information

Thompson s Group F (p + 1) is not Minimally Almost Convex

Thompson s Group F (p + 1) is not Minimally Almost Convex Thompso s Group F (p + ) is ot Miimally Almost Covex Claire Wladis Thompso s Group F (p + ). A Descriptio of F (p + ) Thompso s group F (p + ) ca be defied as the group of piecewiseliear orietatio-preservig

More information

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis

More information

A Note on Least-norm Solution of Global WireWarping

A Note on Least-norm Solution of Global WireWarping A Note o Least-orm Solutio of Global WireWarpig Charlie C. L. Wag Departmet of Mechaical ad Automatio Egieerig The Chiese Uiversity of Hog Kog Shati, N.T., Hog Kog E-mail: cwag@mae.cuhk.edu.hk Abstract

More information

condition w i B i S maximum u i

condition w i B i S maximum u i ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility

More information

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis Outlie ad Readig Aalysis of Algorithms Iput Algorithm Output Ruig time ( 3.) Pseudo-code ( 3.2) Coutig primitive operatios ( 3.3-3.) Asymptotic otatio ( 3.6) Asymptotic aalysis ( 3.7) Case study Aalysis

More information

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method A ew Morphological 3D Shape Decompositio: Grayscale Iterframe Iterpolatio Method D.. Vizireau Politehica Uiversity Bucharest, Romaia ae@comm.pub.ro R. M. Udrea Politehica Uiversity Bucharest, Romaia mihea@comm.pub.ro

More information

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5 Morga Kaufma Publishers 26 February, 28 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Set-Associative Cache Architecture Performace Summary Whe CPU performace icreases:

More information

Examples and Applications of Binary Search

Examples and Applications of Binary Search Toy Gog ITEE Uiersity of Queeslad I the secod lecture last week we studied the biary search algorithm that soles the problem of determiig if a particular alue appears i a sorted list of iteger or ot. We

More information

On (K t e)-saturated Graphs

On (K t e)-saturated Graphs Noame mauscript No. (will be iserted by the editor O (K t e-saturated Graphs Jessica Fuller Roald J. Gould the date of receipt ad acceptace should be iserted later Abstract Give a graph H, we say a graph

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Ruig Time of a algorithm Ruig Time Upper Bouds Lower Bouds Examples Mathematical facts Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite

More information

3D Model Retrieval Method Based on Sample Prediction

3D Model Retrieval Method Based on Sample Prediction 20 Iteratioal Coferece o Computer Commuicatio ad Maagemet Proc.of CSIT vol.5 (20) (20) IACSIT Press, Sigapore 3D Model Retrieval Method Based o Sample Predictio Qigche Zhag, Ya Tag* School of Computer

More information

Improved Random Graph Isomorphism

Improved Random Graph Isomorphism Improved Radom Graph Isomorphism Tomek Czajka Gopal Paduraga Abstract Caoical labelig of a graph cosists of assigig a uique label to each vertex such that the labels are ivariat uder isomorphism. Such

More information

DATA STRUCTURES. amortized analysis binomial heaps Fibonacci heaps union-find. Data structures. Appetizer. Appetizer

DATA STRUCTURES. amortized analysis binomial heaps Fibonacci heaps union-find. Data structures. Appetizer. Appetizer Data structures DATA STRUCTURES Static problems. Give a iput, produce a output. Ex. Sortig, FFT, edit distace, shortest paths, MST, max-flow,... amortized aalysis biomial heaps Fiboacci heaps uio-fid Dyamic

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Higher-order iterative methods free from second derivative for solving nonlinear equations

Higher-order iterative methods free from second derivative for solving nonlinear equations Iteratioal Joural of the Phsical Scieces Vol 6(8, pp 887-89, 8 April, Available olie at http://wwwacademicjouralsorg/ijps DOI: 5897/IJPS45 ISSN 99-95 Academic Jourals Full Legth Research Paper Higher-order

More information

Algorithm. Counting Sort Analysis of Algorithms

Algorithm. Counting Sort Analysis of Algorithms Algorithm Coutig Sort Aalysis of Algorithms Assumptios: records Coutig sort Each record cotais keys ad data All keys are i the rage of 1 to k Space The usorted list is stored i A, the sorted list will

More information

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The

More information

CIS 121. Introduction to Trees

CIS 121. Introduction to Trees CIS 121 Itroductio to Trees 1 Tree ADT Tree defiitio q A tree is a set of odes which may be empty q If ot empty, the there is a distiguished ode r, called root ad zero or more o-empty subtrees T 1, T 2,

More information

An Efficient Algorithm for Graph Bisection of Triangularizations

An Efficient Algorithm for Graph Bisection of Triangularizations A Efficiet Algorithm for Graph Bisectio of Triagularizatios Gerold Jäger Departmet of Computer Sciece Washigto Uiversity Campus Box 1045 Oe Brookigs Drive St. Louis, Missouri 63130-4899, USA jaegerg@cse.wustl.edu

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The

More information

Load balanced Parallel Prime Number Generator with Sieve of Eratosthenes on Cluster Computers *

Load balanced Parallel Prime Number Generator with Sieve of Eratosthenes on Cluster Computers * Load balaced Parallel Prime umber Geerator with Sieve of Eratosthees o luster omputers * Soowook Hwag*, Kyusik hug**, ad Dogseug Kim* *Departmet of Electrical Egieerig Korea Uiversity Seoul, -, Rep. of

More information

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:

More information

n n B. How many subsets of C are there of cardinality n. We are selecting elements for such a

n n B. How many subsets of C are there of cardinality n. We are selecting elements for such a 4. [10] Usig a combiatorial argumet, prove that for 1: = 0 = Let A ad B be disjoit sets of cardiality each ad C = A B. How may subsets of C are there of cardiality. We are selectig elemets for such a subset

More information

Lecture 2: Spectra of Graphs

Lecture 2: Spectra of Graphs Spectral Graph Theory ad Applicatios WS 20/202 Lecture 2: Spectra of Graphs Lecturer: Thomas Sauerwald & He Su Our goal is to use the properties of the adjacecy/laplacia matrix of graphs to first uderstad

More information

Protected points in ordered trees

Protected points in ordered trees Applied Mathematics Letters 008 56 50 www.elsevier.com/locate/aml Protected poits i ordered trees Gi-Sag Cheo a, Louis W. Shapiro b, a Departmet of Mathematics, Sugkyukwa Uiversity, Suwo 440-746, Republic

More information

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig

More information

Data Structures Week #9. Sorting

Data Structures Week #9. Sorting Data Structures Week #9 Sortig Outlie Motivatio Types of Sortig Elemetary (O( 2 )) Sortig Techiques Other (O(*log())) Sortig Techiques 21.Aralık.2010 Boraha Tümer, Ph.D. 2 Sortig 21.Aralık.2010 Boraha

More information

Massachusetts Institute of Technology Lecture : Theory of Parallel Systems Feb. 25, Lecture 6: List contraction, tree contraction, and

Massachusetts Institute of Technology Lecture : Theory of Parallel Systems Feb. 25, Lecture 6: List contraction, tree contraction, and Massachusetts Istitute of Techology Lecture.89: Theory of Parallel Systems Feb. 5, 997 Professor Charles E. Leiserso Scribe: Guag-Ie Cheg Lecture : List cotractio, tree cotractio, ad symmetry breakig Work-eciet

More information

An Efficient Algorithm for Graph Bisection of Triangularizations

An Efficient Algorithm for Graph Bisection of Triangularizations Applied Mathematical Scieces, Vol. 1, 2007, o. 25, 1203-1215 A Efficiet Algorithm for Graph Bisectio of Triagularizatios Gerold Jäger Departmet of Computer Sciece Washigto Uiversity Campus Box 1045, Oe

More information

Lecture 28: Data Link Layer

Lecture 28: Data Link Layer Automatic Repeat Request (ARQ) 2. Go ack N ARQ Although the Stop ad Wait ARQ is very simple, you ca easily show that it has very the low efficiecy. The low efficiecy comes from the fact that the trasmittig

More information

Graphs. Minimum Spanning Trees. Slides by Rose Hoberman (CMU)

Graphs. Minimum Spanning Trees. Slides by Rose Hoberman (CMU) Graphs Miimum Spaig Trees Slides by Rose Hoberma (CMU) Problem: Layig Telephoe Wire Cetral office 2 Wirig: Naïve Approach Cetral office Expesive! 3 Wirig: Better Approach Cetral office Miimize the total

More information

Lecture 6. Lecturer: Ronitt Rubinfeld Scribes: Chen Ziv, Eliav Buchnik, Ophir Arie, Jonathan Gradstein

Lecture 6. Lecturer: Ronitt Rubinfeld Scribes: Chen Ziv, Eliav Buchnik, Ophir Arie, Jonathan Gradstein 068.670 Subliear Time Algorithms November, 0 Lecture 6 Lecturer: Roitt Rubifeld Scribes: Che Ziv, Eliav Buchik, Ophir Arie, Joatha Gradstei Lesso overview. Usig the oracle reductio framework for approximatig

More information

INTERSECTION CORDIAL LABELING OF GRAPHS

INTERSECTION CORDIAL LABELING OF GRAPHS INTERSECTION CORDIAL LABELING OF GRAPHS G Meea, K Nagaraja Departmet of Mathematics, PSR Egieerig College, Sivakasi- 66 4, Virudhuagar(Dist) Tamil Nadu, INDIA meeag9@yahoocoi Departmet of Mathematics,

More information

Cubic Polynomial Curves with a Shape Parameter

Cubic Polynomial Curves with a Shape Parameter roceedigs of the th WSEAS Iteratioal Coferece o Robotics Cotrol ad Maufacturig Techology Hagzhou Chia April -8 00 (pp5-70) Cubic olyomial Curves with a Shape arameter MO GUOLIANG ZHAO YANAN Iformatio ad

More information

Data Structures and Algorithms. Analysis of Algorithms

Data Structures and Algorithms. Analysis of Algorithms Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output

More information

Homework 1 Solutions MA 522 Fall 2017

Homework 1 Solutions MA 522 Fall 2017 Homework 1 Solutios MA 5 Fall 017 1. Cosider the searchig problem: Iput A sequece of umbers A = [a 1,..., a ] ad a value v. Output A idex i such that v = A[i] or the special value NIL if v does ot appear

More information

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs CHAPTER IV: GRAPH THEORY Sectio : Itroductio to Graphs Sice this class is called Number-Theoretic ad Discrete Structures, it would be a crime to oly focus o umber theory regardless how woderful those topics

More information

The isoperimetric problem on the hypercube

The isoperimetric problem on the hypercube The isoperimetric problem o the hypercube Prepared by: Steve Butler November 2, 2005 1 The isoperimetric problem We will cosider the -dimesioal hypercube Q Recall that the hypercube Q is a graph whose

More information

New Results on Energy of Graphs of Small Order

New Results on Energy of Graphs of Small Order Global Joural of Pure ad Applied Mathematics. ISSN 0973-1768 Volume 13, Number 7 (2017), pp. 2837-2848 Research Idia Publicatios http://www.ripublicatio.com New Results o Eergy of Graphs of Small Order

More information

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems

More information

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure

More information

Computers and Scientific Thinking

Computers and Scientific Thinking Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput

More information

Computational Geometry

Computational Geometry Computatioal Geometry Chapter 4 Liear programmig Duality Smallest eclosig disk O the Ageda Liear Programmig Slides courtesy of Craig Gotsma 4. 4. Liear Programmig - Example Defie: (amout amout cosumed

More information

BOOLEAN MATHEMATICS: GENERAL THEORY

BOOLEAN MATHEMATICS: GENERAL THEORY CHAPTER 3 BOOLEAN MATHEMATICS: GENERAL THEORY 3.1 ISOMORPHIC PROPERTIES The ame Boolea Arithmetic was chose because it was discovered that literal Boolea Algebra could have a isomorphic umerical aspect.

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

A Study on the Performance of Cholesky-Factorization using MPI

A Study on the Performance of Cholesky-Factorization using MPI A Study o the Performace of Cholesky-Factorizatio usig MPI Ha S. Kim Scott B. Bade Departmet of Computer Sciece ad Egieerig Uiversity of Califoria Sa Diego {hskim, bade}@cs.ucsd.edu Abstract Cholesky-factorizatio

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

An Improved Shuffled Frog-Leaping Algorithm for Knapsack Problem

An Improved Shuffled Frog-Leaping Algorithm for Knapsack Problem A Improved Shuffled Frog-Leapig Algorithm for Kapsack Problem Zhoufag Li, Ya Zhou, ad Peg Cheg School of Iformatio Sciece ad Egieerig Hea Uiversity of Techology ZhegZhou, Chia lzhf1978@126.com Abstract.

More information

Chapter 3 Classification of FFT Processor Algorithms

Chapter 3 Classification of FFT Processor Algorithms Chapter Classificatio of FFT Processor Algorithms The computatioal complexity of the Discrete Fourier trasform (DFT) is very high. It requires () 2 complex multiplicatios ad () complex additios [5]. As

More information

Fast Fourier Transform (FFT) Algorithms

Fast Fourier Transform (FFT) Algorithms Fast Fourier Trasform FFT Algorithms Relatio to the z-trasform elsewhere, ozero, z x z X x [ ] 2 ~ elsewhere,, ~ e j x X x x π j e z z X X π 2 ~ The DFS X represets evely spaced samples of the z- trasform

More information

1.2 Binomial Coefficients and Subsets

1.2 Binomial Coefficients and Subsets 1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =

More information

Image Segmentation EEE 508

Image Segmentation EEE 508 Image Segmetatio Objective: to determie (etract) object boudaries. It is a process of partitioig a image ito distict regios by groupig together eighborig piels based o some predefied similarity criterio.

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

quality/quantity peak time/ratio

quality/quantity peak time/ratio Semi-Heap ad Its Applicatios i Touramet Rakig Jie Wu Departmet of omputer Sciece ad Egieerig Florida Atlatic Uiversity oca Rato, FL 3343 jie@cse.fau.edu September, 00 . Itroductio ad Motivatio. relimiaries

More information

15-859E: Advanced Algorithms CMU, Spring 2015 Lecture #2: Randomized MST and MST Verification January 14, 2015

15-859E: Advanced Algorithms CMU, Spring 2015 Lecture #2: Randomized MST and MST Verification January 14, 2015 15-859E: Advaced Algorithms CMU, Sprig 2015 Lecture #2: Radomized MST ad MST Verificatio Jauary 14, 2015 Lecturer: Aupam Gupta Scribe: Yu Zhao 1 Prelimiaries I this lecture we are talkig about two cotets:

More information

Pattern Recognition Systems Lab 1 Least Mean Squares

Pattern Recognition Systems Lab 1 Least Mean Squares Patter Recogitio Systems Lab 1 Least Mea Squares 1. Objectives This laboratory work itroduces the OpeCV-based framework used throughout the course. I this assigmet a lie is fitted to a set of poits usig

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to

More information

Exact Minimum Lower Bound Algorithm for Traveling Salesman Problem

Exact Minimum Lower Bound Algorithm for Traveling Salesman Problem Exact Miimum Lower Boud Algorithm for Travelig Salesma Problem Mohamed Eleiche GeoTiba Systems mohamed.eleiche@gmail.com Abstract The miimum-travel-cost algorithm is a dyamic programmig algorithm to compute

More information

CSE 417: Algorithms and Computational Complexity

CSE 417: Algorithms and Computational Complexity Time CSE 47: Algorithms ad Computatioal Readig assigmet Read Chapter of The ALGORITHM Desig Maual Aalysis & Sortig Autum 00 Paul Beame aalysis Problem size Worst-case complexity: max # steps algorithm

More information

On Infinite Groups that are Isomorphic to its Proper Infinite Subgroup. Jaymar Talledo Balihon. Abstract

On Infinite Groups that are Isomorphic to its Proper Infinite Subgroup. Jaymar Talledo Balihon. Abstract O Ifiite Groups that are Isomorphic to its Proper Ifiite Subgroup Jaymar Talledo Baliho Abstract Two groups are isomorphic if there exists a isomorphism betwee them Lagrage Theorem states that the order

More information

Accuracy Improvement in Camera Calibration

Accuracy Improvement in Camera Calibration Accuracy Improvemet i Camera Calibratio FaJie L Qi Zag ad Reihard Klette CITR, Computer Sciece Departmet The Uiversity of Aucklad Tamaki Campus, Aucklad, New Zealad fli006, qza001@ec.aucklad.ac.z r.klette@aucklad.ac.z

More information

BASED ON ITERATIVE ERROR-CORRECTION

BASED ON ITERATIVE ERROR-CORRECTION A COHPARISO OF CRYPTAALYTIC PRICIPLES BASED O ITERATIVE ERROR-CORRECTIO Miodrag J. MihaljeviC ad Jova Dj. GoliC Istitute of Applied Mathematics ad Electroics. Belgrade School of Electrical Egieerig. Uiversity

More information

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio,

More information

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000. 5-23 The course that gives CM its Zip Memory Maagemet II: Dyamic Storage Allocatio Mar 6, 2000 Topics Segregated lists Buddy system Garbage collectio Mark ad Sweep Copyig eferece coutig Basic allocator

More information

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures Uiversity of Waterloo Departmet of Electrical ad Computer Egieerig ECE 250 Algorithms ad Data Structures Midterm Examiatio ( pages) Istructor: Douglas Harder February 7, 2004 7:30-9:00 Name (last, first)

More information

Counting Regions in the Plane and More 1

Counting Regions in the Plane and More 1 Coutig Regios i the Plae ad More 1 by Zvezdelia Stakova Berkeley Math Circle Itermediate I Group September 016 1. Overarchig Problem Problem 1 Regios i a Circle. The vertices of a polygos are arraged o

More information

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1 COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,

More information

Optimal Mapped Mesh on the Circle

Optimal Mapped Mesh on the Circle Koferece ANSYS 009 Optimal Mapped Mesh o the Circle doc. Ig. Jaroslav Štigler, Ph.D. Bro Uiversity of Techology, aculty of Mechaical gieerig, ergy Istitut, Abstract: This paper brigs out some ideas ad

More information

A Note on Chromatic Transversal Weak Domination in Graphs

A Note on Chromatic Transversal Weak Domination in Graphs Iteratioal Joural of Mathematics Treds ad Techology Volume 17 Number 2 Ja 2015 A Note o Chromatic Trasversal Weak Domiatio i Graphs S Balamuruga 1, P Selvalakshmi 2 ad A Arivalaga 1 Assistat Professor,

More information

The Counterchanged Crossed Cube Interconnection Network and Its Topology Properties

The Counterchanged Crossed Cube Interconnection Network and Its Topology Properties WSEAS TRANSACTIONS o COMMUNICATIONS Wag Xiyag The Couterchaged Crossed Cube Itercoectio Network ad Its Topology Properties WANG XINYANG School of Computer Sciece ad Egieerig South Chia Uiversity of Techology

More information

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

Improvement of the Orthogonal Code Convolution Capabilities Using FPGA Implementation

Improvement of the Orthogonal Code Convolution Capabilities Using FPGA Implementation Improvemet of the Orthogoal Code Covolutio Capabilities Usig FPGA Implemetatio Naima Kaabouch, Member, IEEE, Apara Dhirde, Member, IEEE, Saleh Faruque, Member, IEEE Departmet of Electrical Egieerig, Uiversity

More information

Relationship between augmented eccentric connectivity index and some other graph invariants

Relationship between augmented eccentric connectivity index and some other graph invariants Iteratioal Joural of Advaced Mathematical Scieces, () (03) 6-3 Sciece Publishig Corporatio wwwsciecepubcocom/idexphp/ijams Relatioship betwee augmeted eccetric coectivity idex ad some other graph ivariats

More information

Algorithms for Disk Covering Problems with the Most Points

Algorithms for Disk Covering Problems with the Most Points Algorithms for Disk Coverig Problems with the Most Poits Bi Xiao Departmet of Computig Hog Kog Polytechic Uiversity Hug Hom, Kowloo, Hog Kog csbxiao@comp.polyu.edu.hk Qigfeg Zhuge, Yi He, Zili Shao, Edwi

More information

Perhaps the method will give that for every e > U f() > p - 3/+e There is o o-trivial upper boud for f() ad ot eve f() < Z - e. seems to be kow, where

Perhaps the method will give that for every e > U f() > p - 3/+e There is o o-trivial upper boud for f() ad ot eve f() < Z - e. seems to be kow, where ON MAXIMUM CHORDAL SUBGRAPH * Paul Erdos Mathematical Istitute of the Hugaria Academy of Scieces ad Reu Laskar Clemso Uiversity 1. Let G() deote a udirected graph, with vertices ad V(G) deote the vertex

More information

A graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n))

A graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n)) ca see that time required to search/sort grows with size of We How do space/time eeds of program grow with iput size? iput. time: cout umber of operatios as fuctio of iput Executio size operatio Assigmet:

More information

Exercise 6 (Week 42) For the foreign students only.

Exercise 6 (Week 42) For the foreign students only. These are the last exercises of the course. Please, remember that to pass exercises, the sum of the poits gathered by solvig the questios ad attedig the exercise groups must be at least 4% ( poits) of

More information

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions Proceedigs of the 10th WSEAS Iteratioal Coferece o APPLIED MATHEMATICS, Dallas, Texas, USA, November 1-3, 2006 316 A Geeralized Set Theoretic Approach for Time ad Space Complexity Aalysis of Algorithms

More information

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1 CS200: Hash Tables Prichard Ch. 13.2 CS200 - Hash Tables 1 Table Implemetatios: average cases Search Add Remove Sorted array-based Usorted array-based Balaced Search Trees O(log ) O() O() O() O(1) O()

More information