A New Algorithm for Tiered Binary Search

Size: px
Start display at page:

Download "A New Algorithm for Tiered Binary Search"

Transcription

1 Int'l Conf. Foundations of Computer Science FCS'17 25 A New Algorithm for Tiered Binary Search Ahmed Tarek Engineering, Physical and Computer Sciences, Montgomery College, Rockville, Maryland, USA Abstract Due to strong application flavor, binary search and its derivatives are researched widely in computing literature. The new concept pertaining to multiple key search strategy was introduced by the author back in Since then, diverse research investigations are performed with a wide variety of multi-key search algorithms. In this paper, a new algorithm for tiered binary search is proposed. The algorithm performs multiple element binary search through tiered key search strategy that optimizes the search space even further compared to other previous versions. Foundational to tiered search is an extension of the basic binary search due to Newton s root search strategy. This enhanced algorithm computes the n-th root of a non-negative real number. The underlying concept pertaining to tiered binary search in finding multiple key elements with a single iteration in an organized search pool is presented, and the related algorithm is formally described. The algorithm is analyzed for clarity. Finally, application and future research avenues are also explored. Keywords: Balanced Binary Search, Binary Root Search Strategy, Multi-key Elements, Search Pool, Search Space Reduction, Tiered Binary Search 1. Introduction Binary Search and its variants are studied extensively in Computer Science literature due to efficiency and strong application flavors. A simple, yet powerful application of Binary Search, which may conveniently be used to compute the n-th root of a positive real number is presented. The algorithm is motivational and foundational to the Tiered Binary Search as proposed in this paper. As articulated, binary search has a vast arena of applications both in and out of the Computer Science literature. So research with variations of the basic binary search opened up the Multiple key search paradigm for the author that dates back to 2004 [1]. The concept pertaining to multi-key search strategy through Balanced Binary Search is presented, and the analysis is carried out. A search algorithm need not always be restricted to computing a single key, x inside of a search pool. This implies that advanced search algorithms could be designed that essentially compare between two array elements [1] to identify the relatively smaller key array elements inside the larger key search pool. With that perception, the concept pertaining to multiple key search strategy was introduced by the author to the computing community back in 2004 [1]. One significant improvement with the proposed multi-key search strategy over the traditional binary search is the effective reduction in the search space, which accelerates the key search computation. Additionally, instead of just two variants of the key search strategy, which are searching the key element either in an ascending or in a descending sorted search pool, four different variants are available to compute - which are an ascending key array searched inside of an ascending search pool, an ascending array searched inside a descending search pool, a descending key array searched in a descending search pool or descending keys located in an ascending search pool. This diversity in computational model has contributed to the application paradigm for the multiple key search algorithms proposed over time ( [2], [4], etc.). Multi-element binary search proposed in [1] keeps on computing the key elements in order beginning with the first key in the larger search pool. The proposed Tiered Binary Search employs a Balanced Binary Search strategy. It starts with the middle element inside of the key array. It detects the position of the middle element in the key array in the larger search pool using a recursive version of the binary search algorithm. Next the algorithm confines searching for the key array portion that contains keys larger than the middle key only in the larger portion of the search pool that contains elements larger than the middle key using the same recursive binary search. For the key elements, which are smaller than the middle key, the algorithm confines its search only in that portion of the search pool, which contains elements smaller than the middle key. Therefore, instead of blindly searching for the keys in the key element array in the larger search pool beginning with the first key and proceeding in succession, the algorithm subdivides the key array elements into two halves, and performs search for each half in one half of the search pool using the recursive binary search. Hence, the proposed algorithm performs the key search through a 2 tiered binary search. Essentially, instead of just blindly looking for a single key in the optimized list at each iteration, the algorithm looks for two different sets of keys in two halves of the search pool; thus performing a tiered binary search. Using two partitions, the algorithm implements a balanced binary search strategy. Hence, the proposed algorithm performs a tiered multiple element binary search strategy, which is computationally more efficient. It is also possible to design an n-tiered balanced binary search algorithm, where n 3. For n tiers, the algorithm subdivides the list of key elements into n equal partitions.

2 26 Int'l Conf. Foundations of Computer Science FCS'17 It then computes the middle key K i for two successive partitions, i and i +1 for each i, i =1, 2,...,(n 1). Assume K 1 is the middle key between partitions 1 and 2. Next the algorithm, computes the exact key locations in the search pool (larger array) for each partitioning key K i, i = 1, 2,...,(n 1). Denoting those index locations by v i, i = 1, 2,...,(n 1) at elements E[v i ], the algorithm confines the search for all keys in the key partition, i that are smaller than K i only within the search pool fragment, which contains elements smaller than E[v i ], and larger than E[v i 1 ], which are essentially the elements y, such that E[v i 1 ] <y< E[v i ]. In the first tier, all elements from the search pool are available to perform binary search to detect the partitioning key elements K i, i =1, 2,...,(n 1). However,inthe second tier, only a portion of the larger list (search pool), which are namely the elements from E[v i 1 +1] through E[v i 1] are available to perform the binary search for the keys that lie within the range of K i 1 through K i, exclusive. Hence, the generalized algorithm performs ann- Tiered Binary Search. The paper is organized as follows. Section 2 introduces the terms and notation used in the paper. Section 3 explores formal foundation of the proposed algorithms. Section 4 describes the nth Root Finding Algorithm, which is motivational and foundational to the proposed tiered binary search algorithms. The analysis of the algorithm follows. Section 5 represents the Tiered Binary Search Algorithm. Initially, the 2 key version of the Tiered Binary Search algorithm is presented, which is followed by the more generalized p- partitioning key version. A part of this section is devoted towards analyzing the algorithm. The search space reduction due to tiered binary search is also considered. Section 6 considers tiered binary search variations for possible search key and search pool combinations. 2. Terms and Notation n: Total number of elements in the larger list, known as the Search Pool. m: Number of keys. Here, m 2, and n>m. L 1 : Search Pool with n given elements. L 2 : List containing m different keys. k i : The ith key in the list, L 2, i =1, 2,...,m. r: List size to key size ratio, which is n m.forn>m, n m > 1. t i : Index position of the ith key, k i in the search pool, L 1. Here 1 t i n. Also, 1 i m. left: Index position of the leftmost element in search pool, L 1. right: Index position of the rightmost element in search pool, L 1. l: Denotes the length of a list (search pool) or a search space. p: Denotes number of partitioning keys for the generalized tiered search. Definition 1: Keygap, g: The number of elements between two successive keys, k i and k i+1 in search pool, L 1 is known as the Keygap. Here, i =1, 2,...,(m 1). For instance, the number of elements in between the keys, k j and k j+1 is, t j+1 t j 1. Therefore, the Keygap between these two keys is, g j = t j+1 t j 1 elements. For uniformly distributed keys in the search pool, L 1, Keygap, g (n m) n m 1 throughout the search pool. Definition 2: Inter-Key Space Elements, I: Elements in between all successive pairs of keys is collectively known as the Inter-Key Space Elements (IKSE). This is denoted by I. Therefore, I = m 1 j=1 (t j+1 t j 1). Ifakeyis not identified inside the larger list, L 1, then I measures the number of elements between the first previous existing key within the search pool and the next succeeding key existent within the search pool. If none of the m keys exist within L 1, I = 0. If there is only 1 key, say the jth key, k j that exists in L 1, then I = (n t j ). If only the first key, k 1 and the last key, k m exist within L 1, then I =(t m - t 1 1). If only the hth and the sth keys are in L 1 such that 1 h<s m, then I = t s - t h - 1. Also, I for other key index combinations may be determined analogously. Definition 3: Search Space Improvement Factor, SSIF: It is ratio of the computational search space, C O,if k individualized keys are searched inside the search pool, arr[], one key at a time to the search space, C T explored by the proposed tiered binary search algorithm. Therefore, SSIF = C O C T. In general, SSIF = C O C T >> 1. The higher is the ratio, SSIF, the better efficiency is encountered through the proposed tiered binary search algorithm. 3. Formal Foundation With multiple key binary search strategy, instead of bluntly looking for a single key inside of a larger list, all keys are simultaneously being searched for. This strategy significantly reduces the computational overhead due to the individualized execution of the search algorithm with only one key element. Multi-key tiered binary search provides with a very high yield with sorted list elements, which is a requirement for binary search. With the proposed search algorithm, there are two sets. One set is, S 1, the search pool (the larger list) of distinct elements where the proposed algorithm is being applied to. The other set, S 2 contains the distinct keys that are required to be mapped onto the set, S 1. Using set theoretic notation, S 1 = n and S 2 = m, and n >> m.iff is the mapping function from S 2 to S 1, then {y = f(x) =x y S 1 & x S 2 }. Therefore, here the mapping function f is an Identity Function, I x, which maps each key element from the domain of keys to the identical element in the co-domain of search pool, L 1. The key index domain for the mapping is, Z + {0} for Java or C ++ programming language implementation. The element index co-domain in the search pool for the mapping is, Z + {0} { 1} for programming language implementation. Assuming all key elements from S 2 may be mapped onto the corresponding elements in set, S 1, the m

3 Int'l Conf. Foundations of Computer Science FCS'17 27 Predicate Logic Model for the mapping becomes, x y(x S 2 (y S 1 (y = x))). Therefore, the negation of the logical statement is, x y(x S 2 (y / S 1 (y x))). Again, if x = k j and y = Item tj, then j(j 0 j n (x = k j ) ((y = Item tj ) (y = x)). With distinct keys and list elements, the proposed algorithm essentially performs an One-to-one mapping from the set, S 2 to the set, S 1, provided that all key elements in set, S 2 exists in set, S 1. The mapping is not Onto, as S 1 = n>> S 2 = m. Since both the keys and the list elements are distinct (by assumption), no two keys map onto the same search pool element. Due to the same reason, no key maps onto 2 or more different search pool elements. As the algorithm simply performs a one-to-one mapping, which is not onto, therefore, the problem of Collision due to Hashing does not arise with the proposed tiered binary search model. Following is the complete predicate logic model that takes these constraints into account. x y z k((((z = f(x)) (y = f(x))) (z = y)) (((y = f(x)) (y = f(k))) (x = k)))). Since the multiple element binary search mapping is not Bijective, the inverse mapping function does not exit. Furthermore, assuming all keys from S 2 exist in, L 1, which is represented by the set, S 1, S 2 becomes a proper subset of S 1. With the set theoretic notation, this becomes, S 2 S 1. In that event, S 2 is a member of the Power Set, Ψ of S 1. Stated formally, S 2 Ψ(S 1 ).Ifsome keys from S 2 are not present in L 1, S 2 S 1. In that event, there is a third set, S 3, which is a subset of both S 2 and S 1 that lies at the set intersection of S 2 and S 1. Therefore, S 3 = S 2 S1. Also, (S 3 S 2 ) (S 3 S 1 ). The Relation, R between the sets, S 2 and S 1 is an Equality Relation, which is a subset of the Cartesian Product, S 2 S 1 between the sets. Hence, S 2 RS 1 is such that {(x, y) R x S 2 y S 1 (y = x)}. Also, R S 2 S 1. Here, R is a binary relation between the sets. This relation, R between S 2 and S 1 is Reflexive, Symmetric and Transitive. Therefore, R is an Equivalence Relation. Initially, the proposed algorithm searches through the entire search pool, L 1 containing n different elements to identify the middle key index position, k m 2.As S 1 = n, therefore, there are n possible one-to-one mappings from S 2 to S 1. Once k m 2 is identified at location t m 2, the smallers keys, k 1 through k m 2 1 is searched for only within the subset of S 1 containing (t m 2 1) search pool elements. The larger keys, k m 2 +1 through k m are explored only within the (n t m 2 1) search pool elements. Hence, due to subset reduction, the key search space is reduced, and eventually, gets optimized. Beginning with the nth root finding algorithm as a variation to pure binary search, which gradually reduces the search space to converge the algorithm to the closest nth root, the proposed tiered binary search algorithm is presented as another variation to binary search. 4. Proposed nth Root Finding Algorithm Following is the nth root finding algorithm that is very efficient, and works fine for any non-negative real number. Algorithm nthroot Purpose: This algorithm computes the nth root of a nonnegative real number. The supplied parameters are: a constant PRECISION = , a non-negative real number: x from keyboard, and the value of positive integer n, where n 2. So, n Z +. Here, Z + is the set of positive integers, and Z + = {1, 2, 3,...}. nth Root Finding algorithm computes the nth root of the supplied non-negative real number, x. Require: n Z +, n 2, and x 0. Ensure: Correct value of the nth root of the supplied real number, x is computed. Here, x 0. Input non-negative real number x from keyboard. {May prompt the user to input x with x 0.} while x<0 do Display only non-negative real numbers are allowed. So, re-enter x from keyboard. {The program goes on prompting the user to re-enter a non-negative real number as long as the user does not enter one.} end while a = 1.0 if x = 0 then Display nth root = 0.0 if x = 1 then Display nth root = 1.0 if x<1.0 then b = x while (a b) >PRECISIONdo midp oint = (a + b)/2.0 if midp oint midp oint midp oint...(n times) <xthen b = midp oint a = midp oint end while Display nth root = midp oint b = x while (b a) >PRECISIONdo midp oint = (a + b)/2.0 if midp oint midp oint midp oint...(n times) <xthen a = midp oint b = midp oint end while Display nth root = midp oint

4 28 Int'l Conf. Foundations of Computer Science FCS' nth Root Finding Algorithm Analysis Here, a modified binary search technique is used to assign an estimate of the nth root to a non-negative real number, x to another variable, root. There are four different cases associated with the computational scenario. Case 1: x =0.0. In this case, the nth root of x =0.0. Case 2:In this case x>0.0 and x<1.0. Following are the steps to compute the nth root: Step 1: Since x<1.0, the nth root lies in between 0.0 and x itself. Step 2: Declare 2 real variables a and b. Initialize, a =1.0, and b = x. So, x < root < 1.0. This is n true, as if x<1.0 and x>0.0, x>x. Step 3: Change, or fine tune the double variables a and b, and make them closer and closer to each other by narrowing the root search space. It is necessary to ensure that the root lies in between a and b. Therefore, the invariant for the search is, b root a. Case 3: In this case, x =1.0. Therefore, with this case, n x =1.0. Case 4: In this case, x>1.0. So, the nth root of x must lie in between 1.0 and x itself. Following are the steps involved in computation: Step 1: Declare two variables a and b. Step 2: Assign a =1.0, and b = x. Step 3: Therefore, the nth root must lie between a and b. Change or fine tune a and b, so that a and b get closer and closer to each other to converge to the actual nth root. In this case, the invariant for the computation is, a root b. 5. Proposed Tiered Binary Search Algorithm Following is the proposed Tiered Binary Search algorithm with m keys, where m 2. Following algorithm uses only 1 partitioning key, which is the middle key in the keys[] array. Algorithm T ieredbinarysearchp 1 mkey Purpose: This algorithm performs m-key Tiered Binary Search with only 1 middle key. The supplied parameters are: Search Pool arr[], having n elements where the keys are to be identified. An array of m different keys, keys[]. Assumption: n >> m. m-key Tiered Binary Search returns the array keylocations[] (in Java) with the computed index positions for m different keys. If a key does not exist, the corresponding position in array keylocations[] contains a 1. Require: Both the arrays arr[] and keys[] are required to be sorted. For this algorithm, both arr[] and keys[] are sorted in ascending order. Ensure: Proper key index positions are identified. int[] keylocations = new int[keys.length] {Number of elements in keylocations[] = m = the number of keys in keys[].} startindex = 0 endindex =(arr.length 1) keyfirst = 0; keylast =(keys.length 1) middlekey =(keyfirst + keylast) /2 keylocations[middlekey] = RecursiveBinarySearch(arr, startindex, endindex, keys[middlekey]); {Determine the middlekey key location in the search pool, arr[].} for i=0 to (middlekey 1) do keylocations[i] = RecursiveBinarySearch(arr, startindex, (keylocations[middlekey] 1), keys[i]) {Use a for loop to determine the key index locations in search pool, arr[] for all keys that are smaller than middlekey.} startindex =(keylocations[i]+1) {Shift start position to index next to current key location.} {Next the algorithm performs a Balanced Binary Search for the keys that are larger than the keys[middlekey].} {Beginning with the last key index location, keylast, at each iteration, the value of i is decreased by 1.} for i=keylast to (middlekey +1) do keylocations[i] = RecursiveBinarySearch(arr, (keylocations[middlekey]+1), endindex, keys[i]) endindex =(keylocations[i] 1) {Shift end position to an index immediately before current key index location.} return keylocations {Return the Java array, keylocations[] containing the m key index positions to the calling program.} A more generalized version as discussed in the following uses k partitioning keys, where k 2. Algorithm T ieredbinarysearchp k mkey Purpose: This algorithm performs m-key Tiered Binary Search with k partitioning keys. The supplied parameters are: Search pool array arr[], having n elements where the keys are to be identified. An array of m different keys, keys[]. Assumption: n >> m. Also, an integer k 2. k determines the number of Partitioning Keys. m-key Tiered Binary Search returns the array keylocations[] (in Java) with the identified index positions of m different keys.

5 Int'l Conf. Foundations of Computer Science FCS'17 29 If a key does not exist, the corresponding key position in array, keylocations[] contains a 1. Require: Both the arrays arr[] and keys[] are required to be sorted. For this algorithm, both arr[] and keys[] are sorted in ascending order. Ensure: Proper key index positions are identified. int[] keylocations = new int[keys.length] {Number of elements in keylocations[] = m = the number of keys in keys[].} int[] keyp artitions = new int[k] {The array to hold the partitioning keys.} int[] partitionindices = new int[k] {partitionindices[] holds the indices of the Partitioning Keys.} startindex = 0 endindex =(arr.length 1) keyfirst = 0; keylast =(keys.length 1) for i=0 to (k 1) do keyp artitions[i] = keys[int(((keylast) / (k + 1)) (i +1))] {Determine each partitioning key in keys[] array, and load it to the corresponding index location in keyp artitions[] array.} partitionindices[i] =int(((keylast) /(k +1)) (i + 1)) {Hold the indices of Partitioning Keys in partitionindices[] array.} keylocations[int(((keylast) /(k +1)) (i +1))] = RecursiveBinarySearch(arr, startindex, endindex, keyp artitions[i]) {Determine the keyp artitions[i] key location in the larger array, arr[].} startindex =(int(((keylast) /(k +1)) (i +1))) + 1 {Shift the start position for the next Partitioning key.} startindex = 0 {The beginning index for key search in the search pool array, arr[].} for i=0 to (k-1) do if i == 0 then indexleft = 0 {Define indexleft as the left index for the current sub-interval inside the key array, keys[]} indexleft = partitionindices[(i 1)]+1 if i<k-1 then indexright = partitionindices[i]-1 {Define indexright as the right index for the current sub-interval in key array, keys[]} indexright =(keys.length 1) {For the last interval, the end interval for the keys array, is the length of keys[] 1.} indexmiddle = int((indexleft + indexright)/2) {Define indexmiddle as the middle index for the current sub-interval in key array, keys[]} keylocations[indexmiddle] = RecursiveBinarySearch(arr, startindex, keylocations[partitionindices[i]-1, keys[indexmiddle]) {Determine the key index location for the key at indexmiddle inside the search pool, arr[]} {Next apply Binary Search to the keys within the range of indexleft and (indexmiddle - 1)} for j=indexleft to (indexmiddle - 1) do keylocations[j] = RecursiveBinarySearch(arr, startindex, (keylocations[indexmiddle]-1), keys[j]) {Use a for loop to determine the key index locations in search pool, arr[] for all keys that are smaller than keys[indexmiddle].} startindex =(keylocations[j]+1) {Shift start index position to 1 index position right to current key index location, keylocations[j].} {This strategy significantly reduces the key index search space.} {Next the algorithm performs a Balanced Binary Search for the keys that are larger than keys[indexmiddle].} startindex = keylocations[indexmiddle] + 1 {Adjust the beginning index for key search inside the search pool, arr[] one position right to keylocations[indexmiddle].} if i == (k-1) then endindex =(arr.length 1) {For the last interval, set endindex to length of arr[] array - 1.} endindex = keylocations[partitionindices[i]]-1 {Adjust the ending index for search interval inside the search pool, arr[] to one position left of the key partitioning index.} for j=indexright to (indexmiddle + 1) do keylocations[j] = RecursiveBinarySearch(arr, startindex, endindex, keys[j]) endindex = (keylocations[j]-1) {Shift the end position in the search pool, arr[] to an index value immediately before the current key location.} startindex = keylocations[partitionindices[i] +1 {Adjust the starting interval for key search inside the search pool, arr[] one position to the right of the end of current search interval in arr[].} return keylocations {Return the Java array, keylocations[] containing m key index positions to the calling program.}

6 30 Int'l Conf. Foundations of Computer Science FCS' Algorithm Analysis The proposed multiple element tiered binary search algorithm performs a balanced nested range-based binary search to optimize the key search space, and hence, improves the search efficiency. This is essentially a list-to-list mapping, where the smaller list has m elements and the larger list, which is the search pool has n elements. Here, m, n Z +. Nested tiered binary search provides with better time and space efficiency. Also, the proposed algorithm balances the computation by performing a balanced binary search. With the simpler 1 partitioning key version, the algorithm finds the middle element in the key array. Here, middle_key_index = m 2. Next, the algorithm performs binary search to find the exact key index location for k middle_key_index inside the search pool, arr[n]. Suppose, k middle_key_index was identified at index position p inside the array, arr[n]. If k middle_key_index does not exist inside, arr[n], the proposed algorithm records the last index before left_index > right_index for the search following through the binary search strategy. Next, the algorithm confines the search for the key elements from index 0 through (middle_key_index-1) inside the sub-array of array, arr[] from arr[0] through arr[p 1], and confines the search for the key elements beginning at index (middle_key_index+1) through m within the subarray, arr[p +1] through arr[n 1] (as index begins at 0). Example 4 (Search Space Optimization): Consider a list, L 1 containing 10 6 elements, and a list, L 2 of keys with 10 3 elements. Then the middle key for L 2 lies at index 499 (assuming indexing begins at 0 and goes up until 999). The middle key will be searched in the space of 10 6 elements. So the binary searches performed will be c log 2 (10 6 ) = c log 10 (10 6 ) log 2 (10). But log 2 (10) is a constant. Denote log 2 (10) by acutec, and c acutec by C. Then the number of searches for the middle partitioning key is 6C. Without partitioning, applying the basic binary search for all 10 3 keys in L 2, the number of searches will be C = 6000C, C is the constant for binary search. With only one partitioning middle key, assume for simplicity, that the keys are uniformly distributed inside the search pool L 1. Then the middle key will be identified half-way at L 1, which is at index So, search for the keys at index 0 through index 498 will be confined only to the elements at index 0 through index For the first element, it will be searched through a space of 499, 999 elements 500, 000. The second element will be searched over a space of 498, , 000 elements, and so. As the list is uniformly distributed, the last element in the first half will be searched through a space of approximately, 2000 elements. So the total search space size is , 750, 000 elements. So the binary search performed will be c log 2 ( ) = C log 10 ( ) 8.1C. Since this is balanced binary search, the algorithm performs another 8.1C binary searches for the keys at index 500 through 999. So the binary search required is (( C) = 16.2C. With the assumption, the search space reduces by a factor of 6000C 16.2C = So, the search space improvement factor, SSIF = Hence, the effective search space may significantly be reduced through the enhanced k-partitioning key version using the proposed multiple key tiered binary search algorithm. 6. Search Variations As articulated before, the nth Root Finding Algorithm is motivational and foundational to the proposed tiered binary search in gradually narrowing down the search space. With different combinations of elements in L 1 and L 2, four optimum search strategies are possible as variations to the proposed algorithm. These are precisely described below. Here, both L 1 and L 2 are sorted. Combination 1: Consider when both L 1 and L 2 are sorted in ascending order. This combination is the most common, and is used throughout this paper. Assume that the middle key, k middle is identified at index t middle with a single partitioning key. So the keys smaller than this partitioning key are searched only within the sub-array, arr[0] through arr[t i 1]. Once a key, k i is identified at index position, t i, the leftmost index is shifted right to t i +1 for this sub-list. The rightmost index remains at its original position. For balanced binary search, keys larger than k middle is searched within the sub-array, arr[t i +1]] through arr[n 1], beginning with the largest key at k (m 1). Once it is identified at index t (m 1), the rightmost index is shifted left to t (m 1) 1 for this sublist. Hence, both left and right index positions are gradually shifted towards the partitioning index, gradually narrowing down the converging search space. Hence, the overall search space is optimized. Combination 2: Consider when L 1 is in ascending order and L 2 is in descending order. Therefore, the keys in L 2 are organized from higher to lower order. Assume that the middle key, k middle is identified at index t middle with a single partitioning key. So, keys smaller than the partitioning key that are located in the right half of the key array are searched only within the sub-array, arr[0] through arr[t i 1] beginning with the smallest key or the last key at k (m 1). Once a key, k i is identified at index position, t i, the rightmost index is shifted left to t i 1 for this sub-list. The leftmost index remains at its original position. As the proposed algorithm performs a balanced binary search, the keys larger than k middle, which are inside the left half of the list are searched only within the sub-array, arr[t i +1] through arr[n 1], beginning with the largest key at k 0. Once it is identified at index location t 0, the leftmost index is shifted left to t 0 +1 for this sublist. Hence, both the left and the right index positions are gradually narrowed down towards the partitioning index, squeezing the key search space.

7 Int'l Conf. Foundations of Computer Science FCS'17 31 Combination 3: Here, both L 1 and L 2 are in descending order. This combination works pretty similarly to that in Combination 1. Assume that the middle key, k middle is identified at index t middle with a single partitioning key. So the keys larger than this partitioning key are searched only within the search pool, arr[0] through arr[t i 1]. Once a key, k i is identified at index position, t i, the leftmost index is shifted right to t i +1 for this sub-list. The rightmost index remains at its original position. As the proposed algorithm performs a balanced binary search, the keys smaller than k middle are searched for only within the sub-array, arr[t i +1] through arr[n 1], beginning with the smallest key at k (m 1). Once it is identified at index location t (m 1), the rightmost index is shifted left to t (m 1) 1 for this sublist. Hence, both left and right index positions are gradually shifted towards the partitioning index, optimizing the key search space. Combination 4: With this combination, L 1 is in descending order and L 2 is in ascending order. Therefore, the keys in L 2 are organized from lower to higher order. Assume that the middle key, k middle is identified at index t middle with only 1 partitioning key. So the keys smaller than the partitioning key that are located within the left half of the key array are searched only within the sub-array, arr[t i +1] through arr[n 1] beginning with smallest key or the first key at k 0. Once a key, k i is identified at index position, t i, the rightmost index is shifted left to t i 1 for this sub-list. The leftmost index remains at its original position. As the proposed algorithm performs a balanced binary search, the keys larger than k middle, which are located in the right half of the keys array are searched for only within the sub-array, arr[0] through arr[t i 1], beginning with the largest key at k (m 1). Once it is identified at index location t (m 1), the leftmost index is shifted right to t (m 1) +1 for this sublist. Hence, both left and right index positions are gradually shifted narrowing down the overall key search space. Hence, the overall search space is optimized by shifting the boundaries towards the middle key index position. This is the beauty of the proposed computational algorithm in this paper. 7. Conclusion and Future Research This paper proposes a new algorithm for range-based tiered multiple element binary search strategy, and shows the effectiveness of the proposed algorithm in search space reduction. The paper also explores a formal foundation to the proposed algorithm. Examples are incorporated to illustrate the concepts introduced. In future, to demonstrate the overall computational effectiveness of the proposed algorithm, following computation time measurements will be carried out: Both the Search Pool (the larger array) and the Keys are Sorted in Ascending Order. Both the Search Pool and the Keys are Sorted in Descending Order. The Search Pool is Sorted in Ascending Order and the Keys are Sorted in Descending Order. The Search Pool is Sorted in Descending Order and the Keys are Sorted in Ascending Order. Computation times for the above 4 combinations will be compared to each other through graphical as well as tabular means. As per as the computational mechanics is concerned, following will be implemented for algorithmic computation. Beginning with the index position calculated for the middle key in search pool, the left half of the search pool will be searched in ascending order, and right half of the search pool will be searched in descending order of keys. Beginning with the index position computed for the middle key in search pool, the left half of the search pool will be searched in descending order, and right half of the search pool will be searched in ascending order of keys. Beginning with the index position calculated for the middle key in search pool, both the search pool halves will be searched with descending order of keys. Beginning with the index position calculated for the middle key in search pool, both the search pool halves will be searched with ascending order of keys. Binary search is popular due to its logarithmic efficiency, and the strong application flavor. One of the most important future works will be to research out a significant application of the proposed tiered binary search algorithm. In future, the algorithm will be implemented for different key and list order combinations, as outlined above. The related algorithmic performances will be evaluated, and compared to each other. Other performance issues will also be considered in details. References [1] A. Tarek, "A Logarithmic Algorithm for Multi-Key Binary Search," in Proc. SCI 04, 2004, vol. II, pp [2] A. Tarek, "A New Approach for Multiple Element Binary Search in Database Applications," NAUN INTERNATIONAL JOURNAL OF COMPUTERS, vol. 1, pp , Issue 4, [3] A. Tarek, "Multi-key Binary Search and the Related Performance," in Proc. WSEAS American Conference on Applied Mathematics, University of HARVARD, Cambridge, 2008, pp [4] A. Tarek, "A New Algorithm for Multiple Key Interpolation Search in Uniform List of Numbers," Recent Advances in Applied Mathematics and Computational and Information Sciences, vol. II, [5] A. Tarek, "A New Algorithm for Multiple Key Linear Interpolation with the Formal Foundation," in Proc. CSC 14, 2014, paper CSC2003.

A New Algorithm for Multiple Key Interpolation Search in Uniform List of Numbers

A New Algorithm for Multiple Key Interpolation Search in Uniform List of Numbers A New Algorithm for Multiple Key Interpolation Search in Uniform List of Numbers AHMED TAREK California University of Pennsylvania Department of Math and Computer Science 50 University Avenue, California

More information

COMP Data Structures

COMP Data Structures COMP 2140 - Data Structures Shahin Kamali Topic 5 - Sorting University of Manitoba Based on notes by S. Durocher. COMP 2140 - Data Structures 1 / 55 Overview Review: Insertion Sort Merge Sort Quicksort

More information

Sorting and Searching -- Introduction

Sorting and Searching -- Introduction Sorting and Searching -- Introduction Two common programming tasks are sorting a items and searching for an item in a list Chapter 13 focuses on: Selection Sort Insertion Sort A generic sort for objects

More information

Formal Model. Figure 1: The target concept T is a subset of the concept S = [0, 1]. The search agent needs to search S for a point in T.

Formal Model. Figure 1: The target concept T is a subset of the concept S = [0, 1]. The search agent needs to search S for a point in T. Although this paper analyzes shaping with respect to its benefits on search problems, the reader should recognize that shaping is often intimately related to reinforcement learning. The objective in reinforcement

More information

Computer Science 4U Unit 1. Programming Concepts and Skills Algorithms

Computer Science 4U Unit 1. Programming Concepts and Skills Algorithms Computer Science 4U Unit 1 Programming Concepts and Skills Algorithms Algorithm In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation,

More information

CSC 273 Data Structures

CSC 273 Data Structures CSC 273 Data Structures Lecture 6 - Faster Sorting Methods Merge Sort Divides an array into halves Sorts the two halves, Then merges them into one sorted array. The algorithm for merge sort is usually

More information

FINAL EXAM SOLUTIONS

FINAL EXAM SOLUTIONS COMP/MATH 3804 Design and Analysis of Algorithms I Fall 2015 FINAL EXAM SOLUTIONS Question 1 (12%). Modify Euclid s algorithm as follows. function Newclid(a,b) if a

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/ SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All

More information

Principles of Algorithm Design

Principles of Algorithm Design Principles of Algorithm Design When you are trying to design an algorithm or a data structure, it s often hard to see how to accomplish the task. The following techniques can often be useful: 1. Experiment

More information

On Universal Cycles of Labeled Graphs

On Universal Cycles of Labeled Graphs On Universal Cycles of Labeled Graphs Greg Brockman Harvard University Cambridge, MA 02138 United States brockman@hcs.harvard.edu Bill Kay University of South Carolina Columbia, SC 29208 United States

More information

9.5 Equivalence Relations

9.5 Equivalence Relations 9.5 Equivalence Relations You know from your early study of fractions that each fraction has many equivalent forms. For example, 2, 2 4, 3 6, 2, 3 6, 5 30,... are all different ways to represent the same

More information

Cost Models for Query Processing Strategies in the Active Data Repository

Cost Models for Query Processing Strategies in the Active Data Repository Cost Models for Query rocessing Strategies in the Active Data Repository Chialin Chang Institute for Advanced Computer Studies and Department of Computer Science University of Maryland, College ark 272

More information

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A. Functions functions 1 Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A. a A! b B b is assigned to a a A! b B f ( a) = b Notation: If

More information

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 9/e Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Searching data involves determining whether a value (referred to as the search key) is present in the data

More information

Point-Set Topology 1. TOPOLOGICAL SPACES AND CONTINUOUS FUNCTIONS

Point-Set Topology 1. TOPOLOGICAL SPACES AND CONTINUOUS FUNCTIONS Point-Set Topology 1. TOPOLOGICAL SPACES AND CONTINUOUS FUNCTIONS Definition 1.1. Let X be a set and T a subset of the power set P(X) of X. Then T is a topology on X if and only if all of the following

More information

Functions. How is this definition written in symbolic logic notation?

Functions. How is this definition written in symbolic logic notation? functions 1 Functions Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A. We write f(a) = b if b is the unique element of B assigned by

More information

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri 1 Introduction Today, we will introduce a fundamental algorithm design paradigm,

More information

The divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems.

The divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems. 2.3 Designing algorithms There are many ways to design algorithms. Insertion sort uses an incremental approach: having sorted the subarray A[1 j - 1], we insert the single element A[j] into its proper

More information

Computing intersections in a set of line segments: the Bentley-Ottmann algorithm

Computing intersections in a set of line segments: the Bentley-Ottmann algorithm Computing intersections in a set of line segments: the Bentley-Ottmann algorithm Michiel Smid October 14, 2003 1 Introduction In these notes, we introduce a powerful technique for solving geometric problems.

More information

Unit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION

Unit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION DESIGN AND ANALYSIS OF ALGORITHMS Unit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION http://milanvachhani.blogspot.in EXAMPLES FROM THE SORTING WORLD Sorting provides a good set of examples for analyzing

More information

8/5/10 TODAY'S OUTLINE. Recursion COMP 10 EXPLORING COMPUTER SCIENCE. Revisit search and sorting using recursion. Recursion WHAT DOES THIS CODE DO?

8/5/10 TODAY'S OUTLINE. Recursion COMP 10 EXPLORING COMPUTER SCIENCE. Revisit search and sorting using recursion. Recursion WHAT DOES THIS CODE DO? 8/5/10 TODAY'S OUTLINE Recursion COMP 10 EXPLORING COMPUTER SCIENCE Revisit search and sorting using recursion Binary search Merge sort Lecture 8 Recursion WHAT DOES THIS CODE DO? A function is recursive

More information

Data Partitioning. Figure 1-31: Communication Topologies. Regular Partitions

Data Partitioning. Figure 1-31: Communication Topologies. Regular Partitions Data In single-program multiple-data (SPMD) parallel programs, global data is partitioned, with a portion of the data assigned to each processing node. Issues relevant to choosing a partitioning strategy

More information

CMSC 754 Computational Geometry 1

CMSC 754 Computational Geometry 1 CMSC 754 Computational Geometry 1 David M. Mount Department of Computer Science University of Maryland Fall 2005 1 Copyright, David M. Mount, 2005, Dept. of Computer Science, University of Maryland, College

More information

Binary Search to find item in sorted array

Binary Search to find item in sorted array Binary Search to find item in sorted array January 15, 2008 QUESTION: Suppose we are given a sorted list A[1..n] (as an array), of n real numbers: A[1] A[2] A[n]. Given a real number x, decide whether

More information

Faster Sorting Methods

Faster Sorting Methods Faster Sorting Methods Chapter 9 Contents Merge Sort Merging Arrays Recursive Merge Sort The Efficiency of Merge Sort Iterative Merge Sort Merge Sort in the Java Class Library Contents Quick Sort The Efficiency

More information

PRAM Divide and Conquer Algorithms

PRAM Divide and Conquer Algorithms PRAM Divide and Conquer Algorithms (Chapter Five) Introduction: Really three fundamental operations: Divide is the partitioning process Conquer the the process of (eventually) solving the eventual base

More information

Lecture 9 March 4, 2010

Lecture 9 March 4, 2010 6.851: Advanced Data Structures Spring 010 Dr. André Schulz Lecture 9 March 4, 010 1 Overview Last lecture we defined the Least Common Ancestor (LCA) and Range Min Query (RMQ) problems. Recall that an

More information

On the Max Coloring Problem

On the Max Coloring Problem On the Max Coloring Problem Leah Epstein Asaf Levin May 22, 2010 Abstract We consider max coloring on hereditary graph classes. The problem is defined as follows. Given a graph G = (V, E) and positive

More information

Analysis of Algorithms. Unit 4 - Analysis of well known Algorithms

Analysis of Algorithms. Unit 4 - Analysis of well known Algorithms Analysis of Algorithms Unit 4 - Analysis of well known Algorithms 1 Analysis of well known Algorithms Brute Force Algorithms Greedy Algorithms Divide and Conquer Algorithms Decrease and Conquer Algorithms

More information

Basic Properties The Definition of Catalan Numbers

Basic Properties The Definition of Catalan Numbers 1 Basic Properties 1.1. The Definition of Catalan Numbers There are many equivalent ways to define Catalan numbers. In fact, the main focus of this monograph is the myriad combinatorial interpretations

More information

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method.

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method. Reals 1 13 Reals Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method. 13.1 Floating-point numbers Real numbers, those declared to be

More information

CSE 20 DISCRETE MATH. Fall

CSE 20 DISCRETE MATH. Fall CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Final exam The final exam is Saturday December 16 11:30am-2:30pm. Lecture A will take the exam in Lecture B will take the exam

More information

6 Distributed data management I Hashing

6 Distributed data management I Hashing 6 Distributed data management I Hashing There are two major approaches for the management of data in distributed systems: hashing and caching. The hashing approach tries to minimize the use of communication

More information

The Encoding Complexity of Network Coding

The Encoding Complexity of Network Coding The Encoding Complexity of Network Coding Michael Langberg Alexander Sprintson Jehoshua Bruck California Institute of Technology Email: mikel,spalex,bruck @caltech.edu Abstract In the multicast network

More information

Algorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms

Algorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Algorithm Efficiency & Sorting Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Overview Writing programs to solve problem consists of a large number of decisions how to represent

More information

Lower estimate of the square-to-linear ratio for regular Peano curves

Lower estimate of the square-to-linear ratio for regular Peano curves DOI 10.1515/dma-2014-0012 Discrete Math. Appl. 2014; 24 (3):123 12 Konstantin E. Bauman Lower estimate of the square-to-linear ratio for regular Peano curves Abstract: We prove that the square-to-linear

More information

Prefix Computation and Sorting in Dual-Cube

Prefix Computation and Sorting in Dual-Cube Prefix Computation and Sorting in Dual-Cube Yamin Li and Shietung Peng Department of Computer Science Hosei University Tokyo - Japan {yamin, speng}@k.hosei.ac.jp Wanming Chu Department of Computer Hardware

More information

CSC Discrete Math I, Spring Sets

CSC Discrete Math I, Spring Sets CSC 125 - Discrete Math I, Spring 2017 Sets Sets A set is well-defined, unordered collection of objects The objects in a set are called the elements, or members, of the set A set is said to contain its

More information

II (Sorting and) Order Statistics

II (Sorting and) Order Statistics II (Sorting and) Order Statistics Heapsort Quicksort Sorting in Linear Time Medians and Order Statistics 8 Sorting in Linear Time The sorting algorithms introduced thus far are comparison sorts Any comparison

More information

9/24/ Hash functions

9/24/ Hash functions 11.3 Hash functions A good hash function satis es (approximately) the assumption of SUH: each key is equally likely to hash to any of the slots, independently of the other keys We typically have no way

More information

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 2. O(n) 2. [1 pt] What is the solution to the recurrence T(n) = T(n/2) + n, T(1)

More information

2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006

2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006 2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006 The Encoding Complexity of Network Coding Michael Langberg, Member, IEEE, Alexander Sprintson, Member, IEEE, and Jehoshua Bruck,

More information

Solutions to Problem Set 1

Solutions to Problem Set 1 CSCI-GA.3520-001 Honors Analysis of Algorithms Solutions to Problem Set 1 Problem 1 An O(n) algorithm that finds the kth integer in an array a = (a 1,..., a n ) of n distinct integers. Basic Idea Using

More information

Computational Geometry

Computational Geometry Windowing queries Windowing Windowing queries Zoom in; re-center and zoom in; select by outlining Windowing Windowing queries Windowing Windowing queries Given a set of n axis-parallel line segments, preprocess

More information

26 The closest pair problem

26 The closest pair problem The closest pair problem 1 26 The closest pair problem Sweep algorithms solve many kinds of proximity problems efficiently. We present a simple sweep that solves the two-dimensional closest pair problem

More information

Relational Database: The Relational Data Model; Operations on Database Relations

Relational Database: The Relational Data Model; Operations on Database Relations Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview

More information

An Optimal Parallel Algorithm for Merging using Multiselection

An Optimal Parallel Algorithm for Merging using Multiselection An Optimal Parallel Algorithm for Merging using Multiselection Narsingh Deo Amit Jain Muralidhar Medidi Department of Computer Science, University of Central Florida, Orlando, FL 32816 Keywords: selection,

More information

Planar Point Location

Planar Point Location C.S. 252 Prof. Roberto Tamassia Computational Geometry Sem. II, 1992 1993 Lecture 04 Date: February 15, 1993 Scribe: John Bazik Planar Point Location 1 Introduction In range searching, a set of values,

More information

Chapter 4. Divide-and-Conquer. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Chapter 4. Divide-and-Conquer. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chapter 4 Divide-and-Conquer Copyright 2007 Pearson Addison-Wesley. All rights reserved. Divide-and-Conquer The most-well known algorithm design strategy: 2. Divide instance of problem into two or more

More information

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph. Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial

More information

Comp 249 Programming Methodology Chapter 11 Recursion

Comp 249 Programming Methodology Chapter 11 Recursion Comp 249 Programming Methodology Chapter 11 Recursion Prof. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been extracted, modified

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Copyright Cengage Learning. All rights reserved. SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All rights reserved.

More information

Binary Search. Roland Backhouse February 5th, 2001

Binary Search. Roland Backhouse February 5th, 2001 1 Binary Search Roland Backhouse February 5th, 2001 Outline 2 An implementation in Java of the card-searching algorithm is presented. Issues concerning the correctness of the implementation are raised

More information

CSE 20 DISCRETE MATH. Winter

CSE 20 DISCRETE MATH. Winter CSE 20 DISCRETE MATH Winter 2017 http://cseweb.ucsd.edu/classes/wi17/cse20-ab/ Final exam The final exam is Saturday March 18 8am-11am. Lecture A will take the exam in GH 242 Lecture B will take the exam

More information

Range Queries. Kuba Karpierz, Bruno Vacherot. March 4, 2016

Range Queries. Kuba Karpierz, Bruno Vacherot. March 4, 2016 Range Queries Kuba Karpierz, Bruno Vacherot March 4, 2016 Range query problems are of the following form: Given an array of length n, I will ask q queries. Queries may ask some form of question about a

More information

2/14/13. Outline. Part 5. Computational Complexity (2) Examples. (revisit) Properties of Growth-rate functions(1/3)

2/14/13. Outline. Part 5. Computational Complexity (2) Examples. (revisit) Properties of Growth-rate functions(1/3) Outline Part 5. Computational Complexity (2) Complexity of Algorithms Efficiency of Searching Algorithms Sorting Algorithms and Their Efficiencies CS 200 Algorithms and Data Structures 1 2 (revisit) Properties

More information

Worst-case running time for RANDOMIZED-SELECT

Worst-case running time for RANDOMIZED-SELECT Worst-case running time for RANDOMIZED-SELECT is ), even to nd the minimum The algorithm has a linear expected running time, though, and because it is randomized, no particular input elicits the worst-case

More information

Computational Geometry

Computational Geometry Windowing queries Windowing Windowing queries Zoom in; re-center and zoom in; select by outlining Windowing Windowing queries Windowing Windowing queries Given a set of n axis-parallel line segments, preprocess

More information

FITTING PIECEWISE LINEAR FUNCTIONS USING PARTICLE SWARM OPTIMIZATION

FITTING PIECEWISE LINEAR FUNCTIONS USING PARTICLE SWARM OPTIMIZATION Suranaree J. Sci. Technol. Vol. 19 No. 4; October - December 2012 259 FITTING PIECEWISE LINEAR FUNCTIONS USING PARTICLE SWARM OPTIMIZATION Pavee Siriruk * Received: February 28, 2013; Revised: March 12,

More information

Divide-and-Conquer. The most-well known algorithm design strategy: smaller instances. combining these solutions

Divide-and-Conquer. The most-well known algorithm design strategy: smaller instances. combining these solutions Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances recursively 3. Obtain solution to original

More information

We assume uniform hashing (UH):

We assume uniform hashing (UH): We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a

More information

Iterative Searching and Sorting

Iterative Searching and Sorting B B Chapter 1 Iterative Searching and Sorting Probably the most important algorithms in all of computer science are the searching and sorting algorithms. They are important because they are so common.

More information

DATA STRUCTURES/UNIT 3

DATA STRUCTURES/UNIT 3 UNIT III SORTING AND SEARCHING 9 General Background Exchange sorts Selection and Tree Sorting Insertion Sorts Merge and Radix Sorts Basic Search Techniques Tree Searching General Search Trees- Hashing.

More information

Connected Components of Underlying Graphs of Halving Lines

Connected Components of Underlying Graphs of Halving Lines arxiv:1304.5658v1 [math.co] 20 Apr 2013 Connected Components of Underlying Graphs of Halving Lines Tanya Khovanova MIT November 5, 2018 Abstract Dai Yang MIT In this paper we discuss the connected components

More information

Comparison Sorts. Chapter 9.4, 12.1, 12.2

Comparison Sorts. Chapter 9.4, 12.1, 12.2 Comparison Sorts Chapter 9.4, 12.1, 12.2 Sorting We have seen the advantage of sorted data representations for a number of applications Sparse vectors Maps Dictionaries Here we consider the problem of

More information

What Secret the Bisection Method Hides? by Namir Clement Shammas

What Secret the Bisection Method Hides? by Namir Clement Shammas What Secret the Bisection Method Hides? 1 What Secret the Bisection Method Hides? by Namir Clement Shammas Introduction Over the past few years I have modified the simple root-seeking Bisection Method

More information

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions. THREE LECTURES ON BASIC TOPOLOGY PHILIP FOTH 1. Basic notions. Let X be a set. To make a topological space out of X, one must specify a collection T of subsets of X, which are said to be open subsets of

More information

Binary Search APRIL 25 TH, 2014

Binary Search APRIL 25 TH, 2014 Binary Search APRIL 25 TH, 2014 The Search Problem One of the most common computational problems (along with sorting) is searching. In its simplest form, the input to the search problem is a list L and

More information

Pebble Sets in Convex Polygons

Pebble Sets in Convex Polygons 2 1 Pebble Sets in Convex Polygons Kevin Iga, Randall Maddox June 15, 2005 Abstract Lukács and András posed the problem of showing the existence of a set of n 2 points in the interior of a convex n-gon

More information

Parameterized graph separation problems

Parameterized graph separation problems Parameterized graph separation problems Dániel Marx Department of Computer Science and Information Theory, Budapest University of Technology and Economics Budapest, H-1521, Hungary, dmarx@cs.bme.hu Abstract.

More information

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Module 07 Lecture - 38 Divide and Conquer: Closest Pair of Points We now look at another divide and conquer algorithm,

More information

Optimal Parallel Randomized Renaming

Optimal Parallel Randomized Renaming Optimal Parallel Randomized Renaming Martin Farach S. Muthukrishnan September 11, 1995 Abstract We consider the Renaming Problem, a basic processing step in string algorithms, for which we give a simultaneously

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 10 Recursion and Search MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Recursion: General Overview 2 Recursion in Algorithms Recursion is the use of recursive algorithms to

More information

Data Structures and Algorithms Notes

Data Structures and Algorithms Notes Data Structures and Algorithms Notes Notes by Winst Course taught by Dr. G. R. Baliga 256-400 ext. 3890 baliga@rowan.edu Course started: September 4, 2012 Last generated: December 18, 2013 Interfaces -

More information

AtCoder World Tour Finals 2019

AtCoder World Tour Finals 2019 AtCoder World Tour Finals 201 writer: rng 58 February 21st, 2018 A: Magic Suppose that the magician moved the treasure in the order y 1 y 2 y K+1. Here y i y i+1 for each i because it doesn t make sense

More information

Slides for Faculty Oxford University Press All rights reserved.

Slides for Faculty Oxford University Press All rights reserved. Oxford University Press 2013 Slides for Faculty Assistance Preliminaries Author: Vivek Kulkarni vivek_kulkarni@yahoo.com Outline Following topics are covered in the slides: Basic concepts, namely, symbols,

More information

Unit-2 Divide and conquer 2016

Unit-2 Divide and conquer 2016 2 Divide and conquer Overview, Structure of divide-and-conquer algorithms, binary search, quick sort, Strassen multiplication. 13% 05 Divide-and- conquer The Divide and Conquer Paradigm, is a method of

More information

1 Probabilistic analysis and randomized algorithms

1 Probabilistic analysis and randomized algorithms 1 Probabilistic analysis and randomized algorithms Consider the problem of hiring an office assistant. We interview candidates on a rolling basis, and at any given point we want to hire the best candidate

More information

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics. Fundamental mathematical techniques reviewed: Mathematical induction Recursion Typically taught in courses such as Calculus and Discrete Mathematics. Techniques introduced: Divide-and-Conquer Algorithms

More information

Seminar on. A Coarse-Grain Parallel Formulation of Multilevel k-way Graph Partitioning Algorithm

Seminar on. A Coarse-Grain Parallel Formulation of Multilevel k-way Graph Partitioning Algorithm Seminar on A Coarse-Grain Parallel Formulation of Multilevel k-way Graph Partitioning Algorithm Mohammad Iftakher Uddin & Mohammad Mahfuzur Rahman Matrikel Nr: 9003357 Matrikel Nr : 9003358 Masters of

More information

CS 1200 Discrete Math Math Preliminaries. A.R. Hurson 323 CS Building, Missouri S&T

CS 1200 Discrete Math Math Preliminaries. A.R. Hurson 323 CS Building, Missouri S&T CS 1200 Discrete Math A.R. Hurson 323 CS Building, Missouri S&T hurson@mst.edu 1 Course Objective: Mathematical way of thinking in order to solve problems 2 Variable: holder. A variable is simply a place

More information

General properties of staircase and convex dual feasible functions

General properties of staircase and convex dual feasible functions General properties of staircase and convex dual feasible functions JÜRGEN RIETZ, CLÁUDIO ALVES, J. M. VALÉRIO de CARVALHO Centro de Investigação Algoritmi da Universidade do Minho, Escola de Engenharia

More information

Sorting Pearson Education, Inc. All rights reserved.

Sorting Pearson Education, Inc. All rights reserved. 1 19 Sorting 2 19.1 Introduction (Cont.) Sorting data Place data in order Typically ascending or descending Based on one or more sort keys Algorithms Insertion sort Selection sort Merge sort More efficient,

More information

Quartile, Deciles, Percentile) Prof. YoginderVerma. Prof. Pankaj Madan Dean- FMS Gurukul Kangri Vishwavidyalaya, Haridwar

Quartile, Deciles, Percentile) Prof. YoginderVerma. Prof. Pankaj Madan Dean- FMS Gurukul Kangri Vishwavidyalaya, Haridwar Paper:5, Quantitative Techniques for Management Decisions Module:6 Measures of Central Tendency: Averages of Positions (Median, Mode, Quartile, Deciles, Percentile) Principal Investigator Co-Principal

More information

Module 2: Classical Algorithm Design Techniques

Module 2: Classical Algorithm Design Techniques Module 2: Classical Algorithm Design Techniques Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Module

More information

Online algorithms for clustering problems

Online algorithms for clustering problems University of Szeged Department of Computer Algorithms and Artificial Intelligence Online algorithms for clustering problems Summary of the Ph.D. thesis by Gabriella Divéki Supervisor Dr. Csanád Imreh

More information

Randomized Algorithms: Selection

Randomized Algorithms: Selection Randomized Algorithms: Selection CSE21 Winter 2017, Day 25 (B00), Day 16 (A00) March 15, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Selection Problem: WHAT Given list of distinct integers a 1, a 2,,

More information

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Using Monte Carlo to Estimate π using Buffon s Needle Problem An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Here s the problem (in a simplified form). Suppose

More information

Algorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48

Algorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48 Algorithm Analysis (Algorithm Analysis ) Data Structures and Programming Spring 2018 1 / 48 What is an Algorithm? An algorithm is a clearly specified set of instructions to be followed to solve a problem

More information

Practice Sheet 2 Solutions

Practice Sheet 2 Solutions Practice Sheet 2 Solutions 28th August, 2016 Dynamic Programming 1. Question: Given an array of n positive integers a 1,, a n, give an algorithm to find the length of the longest subsequence a i1,, a ik

More information

Computer Science 252 Problem Solving with Java The College of Saint Rose Spring Topic Notes: Searching and Sorting

Computer Science 252 Problem Solving with Java The College of Saint Rose Spring Topic Notes: Searching and Sorting Computer Science 5 Problem Solving with Java The College of Saint Rose Spring 016 Topic Notes: Searching and Sorting Searching We all know what searching is looking for something. In a computer program,

More information

High Dimensional Indexing by Clustering

High Dimensional Indexing by Clustering Yufei Tao ITEE University of Queensland Recall that, our discussion so far has assumed that the dimensionality d is moderately high, such that it can be regarded as a constant. This means that d should

More information

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015 CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015 1 Introduction Today, we will introduce a fundamental algorithm design paradigm, Divide-And-Conquer,

More information

Computer Science 210 Data Structures Siena College Fall Topic Notes: Searching and Sorting

Computer Science 210 Data Structures Siena College Fall Topic Notes: Searching and Sorting Computer Science 10 Data Structures Siena College Fall 016 Topic Notes: Searching and Sorting Searching We all know what searching is looking for something. In a computer program, the search could be:

More information

Laboratory Module X B TREES

Laboratory Module X B TREES Purpose: Purpose 1... Purpose 2 Purpose 3. Laboratory Module X B TREES 1. Preparation Before Lab When working with large sets of data, it is often not possible or desirable to maintain the entire structure

More information

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings On the Relationships between Zero Forcing Numbers and Certain Graph Coverings Fatemeh Alinaghipour Taklimi, Shaun Fallat 1,, Karen Meagher 2 Department of Mathematics and Statistics, University of Regina,

More information

Lecture 13: AVL Trees and Binary Heaps

Lecture 13: AVL Trees and Binary Heaps Data Structures Brett Bernstein Lecture 13: AVL Trees and Binary Heaps Review Exercises 1. ( ) Interview question: Given an array show how to shue it randomly so that any possible reordering is equally

More information

Recursion. Let s start by looking at some problems that are nicely solved using recursion. First, let s look at generating The Fibonacci series.

Recursion. Let s start by looking at some problems that are nicely solved using recursion. First, let s look at generating The Fibonacci series. Recursion The programs we have discussed so far have been primarily iterative and procedural. Code calls other methods in a hierarchical manner. For some problems, it is very useful to have the methods

More information

SPERNER S LEMMA, BROUWER S FIXED-POINT THEOREM, AND THE SUBDIVISION OF SQUARES INTO TRIANGLES

SPERNER S LEMMA, BROUWER S FIXED-POINT THEOREM, AND THE SUBDIVISION OF SQUARES INTO TRIANGLES SPERNER S LEMMA, BROUWER S FIXED-POINT THEOREM, AND THE SUBDIVISION OF SQUARES INTO TRIANGLES AKHIL MATHEW Abstract These are notes from a talk I gave for high-schoolers at the Harvard- MIT Mathematics

More information

Eulerian disjoint paths problem in grid graphs is NP-complete

Eulerian disjoint paths problem in grid graphs is NP-complete Discrete Applied Mathematics 143 (2004) 336 341 Notes Eulerian disjoint paths problem in grid graphs is NP-complete Daniel Marx www.elsevier.com/locate/dam Department of Computer Science and Information

More information