The International Arab Journal of Information Technology, Vol. 7, No. 1, January 2010 55

An Enhancement of Major Sorting Algorithms

Jehad Alnihoud and Rami Mansi Department of Computer Science, Al alBayt University, Jordan

Abstract: One of the fundamental issues in computer science is ordering a list of items. Although there is a huge number of sorting algorithms, sorting problem has attracted a great deal of research; because efficient sorting is important to optimize the use of other algorithms. This paper presents two new sorting algorithms, enhanced and enhanced algorithms. Enhanced selection sort is an enhancement on selection sort by making it slightly faster and stable . Enhanced bubble sort is an enhancement on both bubble sort and selection sort algorithms with O(nlgn) complexity instead of O(n 2) for bubble sort and selection sort algorithms. The two new algorithms are analyzed, implemented, tested, and compared and the results were promising .

Keywords: Enhanced selection sort, enhanced bubble sort, selection sort, bubble sort, number of swaps, .

Received May 27, 2008; accepted September 1, 2008

1. Introduction the complexity of solving it efficiently. Bubble sort was analyzed as early as 1956 [2]. Information growth rapidly in our world and to search Many researchers considered sorting as a solved for this information, it should be ordered in some problem. Even so, useful new sorting algorithms are sensible order. Many years ago, it was estimated that still being invented, for example, was first more than half the time on many commercial computers published in 2004. Sorting algorithms are prevalent in was spent in sorting. Fortunately this is no longer true, introductory computer science classes, where the since sophisticated methods have been devised for abundance of algorithms for the problem provides a organizing data, methods which do not require that the gentle introduction to a variety of core algorithm data be kept in any special order [9]. concepts [1, 19]. In [1], they classified sorting Many algorithms are very well known for sorting the algorithms by: unordered lists. Most important of them are Heap sort, Bubble sort, and shell sort [17]. As stated • Computational complexity (worst, average and best in [5], sorting has been considered as a fundamental behavior) of element comparisons in terms of list problem in the study of algorithms, that due to many size ( n). For typical sorting algorithms good reasons: behavior is O(n log n) and bad behavior is ( n²). Ideal behavior for a sort is O( n). Sort algorithms • The need to sort information is inherent in many which only use an abstract key comparison applications. operation always need ( n log n) comparisons in • Algorithms often use sorting as a key subroutine. the worst case. • In algorithm design there are many essential • Number of swaps (for inplace algorithms). techniques represented in the body of sorting • Stability: stable sorting algorithms maintain the algorithms. relative order of records with equal keys (values). • Many engineering issues come to the fore when That is, a sorting algorithm is stable if whenever implementing sorting algorithms. there are two records R and S with the same key Efficient sorting is important to optimize the use of and with R appearing before S in the original list, R other algorithms that require sorted lists to work will appear before S in the sorted list. correctly; it is also often in producing humanreadable • Usage of memory and other computer resources. output. Formally, the output should satisfy two major Some sorting algorithms are “in place”, such that conditions: only O(1) or O(log n) memory is needed beyond the items being sorted, while others need to create • The output is in nondecreasing order. auxiliary locations for data to be temporarily stored. • The output is a permutation, or reordering, of the • Recursion: some algorithms are either recursive or input. non recursive, while others may be both (e.g., Since the early beginning of computing, the sorting ). problem has attracted many researchers, perhaps due to • Whether or not they are a . A comparison sort examines the data only by 56 The International Arab Journal of Information Technology, Vol. 7, No. 1, January 2010

comparing two elements with a comparison operator. 4 max := array(index) 5 for a:= 0 to size2 do In this paper, two new sorting algorithms are 6 if array(a) ≥ max then presented. These new algorithms may consider as 7 max := array(a) selection sort as well as bubble sort algorithms. The 8 index := a study shows that the proposed algorithms are more 9 end if efficient, theoretically, analytically, and practically as 10 end for compared to the original sorting algorithms. Section 2 11 if index ≠ size1 then presents the concept of enhanced Selection Sort (SS) 12 temp := array(size1) algorithm and its pseudocode. Furthermore, the 13 array(size1) := max 14 array(index) := temp implementation, analysis, and comparison with 15 end if selection sort are highlighted. Section 3 introduces 16 size := size1 enhanced bubble sort algorithm and its pseudocode, 17 return Enhanced Selection Sort (array , size) implementation, analysis, and comparison with bubble 18 else sort. Also, a realworld case study for the proposed 19 return array algorithms is presented in section 4. Finally, 20 end if conclusions were presented in section 5. 2.4. Analysis 2. Enhanced Selection Sort For loop, in line 5 iterates n times in the first call then 2.1. Concept n keeps decreasing by one. We may say that:  0 n = 0 T ( n ) =  (1) Inserting an array of elements and sorting these  n + T ( n − )1 n > 0 elements in the same array (inplace) by finding the maximum element and exchanging it with the last T(n) = n + T(n1) element, and then decreasing the size of the array by = n + n1 + T(n2) one for next call. In fact, the Enhanced Selection Sort = n + n1 + n2 + T(n3) (2) (ESS) algorithm is an enhancement to the SS algorithm = n + n1 + n2 + n3 + T(n4) in decreasing number of swap operations, making the = … = n + n1 + n2 + n3 + … + algorithm to be data dependent, and in making it stable. (n k+1) + T(nk) The differences between ESS and SS algorithms are discussed in section 2.5. n = ∑ i + T ( n − , fkor) n ≥ k i=n−k +1 2.2. Procedures To terminate the recursion, we should have n k = 0 The procedures of the algorithms can be described as => k = n: follows: n n n+1 • Inserting all elements of the array. ∑ i + T )0( = ∑ i + 0 = n (3) i=1 i=1 2 • Calling the “Enhanced Selection Sort” function with n + 1 T ( n ) = n = O ( n 2 ) passing the array and its size as parameters. So, 2 (4) • Finding the maximum element in the array and swapping it with the last index of the same array. ESS algorithm is easy to analyze compared to other • Decreasing the size of the array by one. sorting algorithms since the loop does not depend on • Calling the “Enhanced Selection Sort” function the data in the array. Selecting the highest element recursively. The size of the array is decremented by requires scanning all n elements (this takes n 1 one after each call of the “Enhanced Selection Sort” comparisons) and then swapping it into the last function. Operationally, the ( size ) after the first call position. Then, finding the next highest element became ( size1), and after the second call became requires scanning the remaining n 2 elements and so (size2), and so on. on, for ( n1)+( n2)+...+2+1 = n(n1)/2 = O( n2) comparisons. 2.3. Pseudocode The number of swaps in the proposed algorithm may elaborate as follows: In simple pseudocode, enhanced selection sort algorithm might be expressed as: a) In the bestcase scenario; if the input array is already sorted (ascending order), then there is no function enhanced selection sort (array , size) need to make swapping, since each element is in 1 if size > 1 then the correct place. 2 var index, temp, max b) In the averagecase scenario; if the input array is 3 index := size1 sorted in reverse (descending order), then the

An Enhancement of Major Sorting Algorithms 57

total number of swapping operations is: floor of perform any swap operation, but selection sort (n/2). Since swapping the maximum value with the performs n swap operations. Writing in memory is last element means that the maximum and the more expensive in time than reading, since EBS minimum values are in the correct places. For performs less number of swaps (read/write) then it is example, if we have a descending sorted array as more efficient than selection sort when dealing with follows: an array stored in a secondary memory or in EEPROM (electrically erasable programmable read only 5 4 3 2 1 memory). However, there are many similarities Then the algorithm will swap the first element (max) between ESS and SS algorithms, as shown in Table 1. with the last element, as follows: Table 1. ESS vs SS algorithms.

1 4 3 2 5 Enhanced Selection Criteria Selection Sort Sort Since the last element before swapping was the Best Case O( n2) O( n2) minimum value, it is after swapping got in the correct Average Case O( n2) O( n2) 2 2 place and cannot be the maximum value in any of the Worst Case O( n ) O( n ) Memory O(1) O(1) next comparisons. Stability Yes Yes In the next comparison, the second element now is Depends on data: 0, Number of Swaps Always n the maximum value and it will be swapped with the n/2, or n fourth (size1) th element.

1 2 3 4 5 To prove that ESS algorithm is relatively faster The array now is sorted and the algorithm required than SS algorithm, we implement each of them using two swap operations to sort the input array of five C++, and measure the execution time of both elements. That means, the swapping operations that are programs with the same input data, and using the same needed to sort a descending sorted array is floor of computer. The builtin function (clock ()) in C++ is (n/2). used to get the elapsed time of the two algorithms. c) In the worst case; if the input array is unsorted #include neither ascending nor descending, then the required #include swapping operations are approximately n operations. #include int sort(int[], int); 2.5. Comparison with SS Algorithm void main() { . . . . SS algorithm, works by selecting the smallest unsorted clock_t Start, Time; item remaining in the array, and then swapping it with Start = clock(); the item in the next position to be filled. The selection // the function call goes here sort has a complexity of O(n2) [8, 11]. In simple Time = (clock() Start); pseudocode, selection sort algorithm might be cout<<"Execution Time : "<

Function SelectionSort(array, size) Since the execution time of a program is measured 1 var i, j in milliseconds using this function; we should measure 2 var min, temp execution time of sorting algorithms with a huge size 3 for i := 0 to size2 do of input array. Table 2 shows the differences between 4 min := i execution times of ESS and SS with using an array of 5 for j := i+1 to size1 do (9000) elements in the best, average, and worst cases. 6 if array(j) < array(min) Table 2 shows that Enhanced Bubble Sort (EBS) is 7 min := j relatively faster than selection sort in all cases. That 8 end if because the number of comparisons and swap 9 end for j operations are less. In SS, the number of swaps is 10 temp := array(i) 11 array(i) := array(min) always (8999), which is ( n1), but in ESS, it is ( n) in 12 array(min) := temp the worstcase, ( n/2) in the averagecase, and (0) in the 13 end for i bestcase. If the array is stored in a secondary memory; then the SS will operate in relatively low The main advantage enhanced selection sort over performance as compared with ESS. selection sort algorithms is: selection sort always performs O( n) swaps while enhanced selection sort 3. Enhanced Bubble Sort depends on the state of the input array. In other words, if the input array is already sorted, the ESS does not The history of Bubble sort algorithm may elaborate as follows:

58 The International Arab Journal of Information Technology, Vol. 7, No. 1, January 2010

In 1963 FORTRAN textbook [13] states the 1. Inserting all elements of the array. following code to what so called “Jumpdown” sort. 2. Defining and initializing two variables, (firstindex = 0) and (lastindex = size1). 1 void JumpDownSort(Vector a, int n){ 3. Calling the "Enhanced Bubble Sort" function with 2 for(int j=n1; j > o; j) passing the array, its size, firstindex, and lastindex as 3 for(int k=0; k < j;k++) parameters of the function. 4 if (a[j] < a[k]) 4. In the "Enhanced Bubble Sort" function, the operation 5 Swap(a,k,j);} now is to find the maximum and the minimum elements

and saving the index value of the max of the array in the Table 2. Execution time for ESS vs SS algorithms. variable maxcounter, and the index value of the min in the variable mincounter. Enhanced Selection Case Criteria Selection Sort Sort 5. Put the max in the lastindex and min in the firstindex of the array without losing the last values of the first index Number of 40495500 40504499 and the last index of the original array. comparisons 6. Decreasing the value of lastindex by one and increasing B the value of firstindex by one. Operationally, the size of e Number of swaps 0 8999 the array after the first call became (size2), and after s the second call it actually became (size4), and so on. t 7. Calling the "Enhanced Bubble Sort " array recursively while the size of the array is greater than one (size>1). Elapsed time 125 ms 171 ms Then returning the sorted array.

Number of 40495500 40504499 3.2. Pseudocode A comparisons v The pseudocode of EBS algorithm might be expressed e as: r Number of swaps 4500 8999 a function EnhancedBubbleSort (array, size, firstindex, g e lastindex) Elapsed time 133 ms 203 ms 1 if size > 1 then 2 var temp := 0, maxcounter := lastindex 3 var mincounter := firstindex Number of 4 var max := array(lastindex),min := array(firstindex) 40495500 40504499 comparisons 5 for a:= firstindex to lastindex do W 6 if array(a) ≥ max then o 7 max := array(a) r 8 maxcounter := a s Number of swaps 8999 8999 t 9 end if 10 if array(a) < min then Elapsed time 156 ms 203 ms 11 min := array(a) 12 mincounter := a 13 end if In another early 1962 book [10] “Jumpdown” 14 end for 15 if firstindex==maxcounter AND version appears with no name. In another two early astindex==mincounter then works [3, 7] the “jumpdown” sort is referred to as 17 array(firstindex):= min selection sort. Then bubble sort is also covered and 18 array(lastindex) := max referred as sorting by repeated comparison and 19 else exchanging, respectively. 20 if firstindex==maxcounter AND lastindex ≠ mincounter then 3.1. Concept and Procedures of EBS 21 temp := array(lastindex) 22 array(lastindex) := max The proposed algorithm is considered as an 23 array(firstindex) := min enhancement to the original Bubble sort algorithm and 24 array(mincounter) := temp it works as follows: 25 else Inserting an array of elements and sorting these 26 if firstindex ≠ maxcounter AND elements in the same array (in place) by finding the lastindex==mincounter then minimum and the maximum elements and exchanging 27 temp := array(firstindex) 28 array(firstindex):= min the minimum with the first element and the maximum 29 array(lastindex) := max with the last element, and then decreasing the size of 30 array(maxcounter):= temp the array by two for next call. 31 else The detailed procedures of the algorithm can be 32 temp := array(firstindex) summarized as follows: 33 array(firstindex):= min

An Enhancement of Major Sorting Algorithms 59

34 array(mincounter):= temp 7 array[j] := temp; 35 temp := array(lastindex) 8 end if 36 array(lastindex):= max 9 end for 37 array(maxcounter):= temp 10 end for 38 end if 11 end function 39 end if 40 end if The positions of the elements in bubble sort play an 41 firstindex := firstindex + 1 important role in determining its performance. Large 42 lastindex := lastindex 1 elements at the beginning of the list are quickly 43 size := size – 2 swapped, while small elements at the beginning move 44 return EnhancedBubbleSort (array,size,firstindex,lastindex) to the top extremely slowly. This has led to these types 45 else return array of elements being named rabbits and turtles, 46 end if respectively [2, 20]. BS algorithm makes n comparisons at the first time, and then it makes n1 3.3. Analysis comparisons, and so on [19]. This yields to n + (n1) + (n2) + … + 2 + 1 which is equal to n(n+1)/2 which is The first call of the function loop iterates n times, as O( n2). shown in line 5, and in the second call, the loop iterates In EBS algorithm, decreasing the number of n2 times, and so on. We may analyze the algorithm as comparisons by two each call led the complexity to be follows: O( nlgn ) which is very much better than O( n2). The

T(n) = 1, for n < 2 difference between EBS and BS may not be clear with T(n) = n + T(n2), for n ≥ 2 a small size of the input array, but with a large size it = n + (n2) + T(n4) is very clear that EBS is faster than bubble sort. The = 2n – 2 + T(n4) main differences between EBS and BS are: = 2n – 2 + (n4) + T(n6) • = 3n – 6 + T(n6) In the averagecase; BS performs n/2 swapping = 4n – 12 + T(n8) operations, in the bestcase it performs 0 = 5n – 20 + T(n10) operations, and in the worstcase it performs n = … swapping operations, while EBS performs ( n/2) = in – (i 2 i) + T(n – 2i) swapping operations in all cases. 2 = kn – (k k) + T(n – 2k) • Since EBS needs to check the locations of the Assume that: found minimum and maximum elements before k n = 2 , taking lg 2 on both sides: performing swapping to avoid losing data; it has a lg n = k lg 2 larger size of code than Bubble sort. lg n = k * 1 • In all cases, EBS makes O(nlgn ) comparisons and lg n = k Bubble sort makes O(n2) comparisons to sort n Therefore, 2 elements of the input array. kn – (k k) + T(n – 2k)= nlgn – ((lgn) 2 lgn) + T(n – 2lgn) Table 3 shows the main differences between EBC T(n) = O(nlgn) and Bubble sort algorithms:

Table 3. EBS vs BS algorithms. 3.4. Comparison with Bubble Sort Algorithm Enhanced Bubble Bubble Sort (BS) repeatedly stepping through the array Criteria Bubble Sort Sort to be sorted, comparing two items at a time and 2 swapping them if necessarily. Passing through the list is Best Case O( nlgn ) O( n ) repeated until no swaps are needed, which indicates Average Case O( nlgn ) O( n2) that the list is already sorted. The algorithm gets its Worst Case O( nlgn ) O( n2) name from the way smaller elements “bubble” to the Memory O(1) O(1) Stability Yes Yes top of the list. Since it uses comparisons only to operate Depends on data: 0, Number of Swaps Always n/2 on elements, it is a comparison sort [2, 11]. In simple n/2, or n pseudocode, bubble sort algorithm might be expressed as: To be certain about these results we should compute the execution time of the implementation function bubbleSort(array, array_size) 1 var i, j, temp; program of each algorithm. Table 4 shows the 2 for i:=(array_size1)downto 0 step1 differences between execution time of EBS and BS 3 for j := 1 to i do algorithms using C++ with (9000) elements as the size 4 if array(j1) > array(j) then of the input array. 5 temp := array[j1]; 6 array[j1] := array[j];

60 The International Arab Journal of Information Technology, Vol. 7, No. 1, January 2010

From Table 4 we may conclude that EBS is faster Shell sort [18] which is an enhanced version of than bubble sort especially when n is large. This is an insertion sort, reduces the number of swaps of the important advantage of EBS over bubble sort. At the elements being sorted to minimize the complexity and same time, EBS always performs n /2 swap operations time as compared to the insertion sort. Shell sort and it has a larger code size as compared to bubble sort. improves the insertion sort by comparing elements separated by a gap of several positions. This lets an Table 4. Execution time for EBS vs BS algorithms. element take bigger steps toward its expected position. Enhanced Multiple passes over the data are taken with smaller Case Criteria Bubble Sort Bubble Sort and smaller gap sizes. The last step of Shell sort is a Number of 20254500 40504500 B comparisons plain insertion sort, but by then, the array of data is e guaranteed to be almost sorted. s Number of swaps 4500 0 t The shell sort is a “Diminishing Increment Sort”, Elapsed time 93 ms 187 ms better known as a [4] to the unwashed programming masses. The algorithm makes multiple A Number of passes through the list, and each time sorts a number v 20254500 40504500 comparisons e of equally sized sets using the insertion sort [12]. The r size of the set to be sorted gets larger with each pass a through the list, until the set consists of the entire list. g Number of swaps 4500 4500 e This sets the insertion sort up for an almostbest case Elapsed time 109 ms 437 ms run each iteration with a complexity that approaches Number of W 20254500 40504500 O( n). Donald L. shell [18] invented a formula to comparisons o calculate the value of ‘h’. This work focuses to r Number of swaps 4500 9000 s identify some improvement in the conventional Shell t Elapsed time 140 ms 453 ms sort algorithm. As stated in [15, 18], the original implementation of To support the previous results we may compare the Shell sort performs O( n2) comparisons and exchanges proposed algorithms with some recent advanced sorting in the worst case. A minor change given in V. Pratt's algorithms, such as cocktail sort [12], shell sort [18], book [13] which improved the bound to O( n log 2 n). and enhanced shell sort [17]. This is worse than the optimal comparison sorts, Cocktail sort as stated in [12], also known as which are O( n log n). bidirectional BS and , is a variation ESS algorithm [17] is an improvement in the Shell of BS and selection sort that is both a stable sorting sort algorithm to calculate the value of ‘h’. It has been algorithm and a comparison sort. The algorithm differs observed that by applying this algorithm, number of from BS in that it sorts in both directions each pass swaps can be reduced up to 60 percent as compared to through the list. This sorting algorithm is only the shell sort algorithm, but it is still a quadratic marginally more difficult than BS to implement, and sorting algorithm. It is clear that EBS is faster than solves the problem with socalled turtles in BS. shell sort and its variants since all of them makes a In the first stage of the cocktail sort, it loops through quadratic time while EBS makes a O( nlgn ) time to the array from bottom to top, as in BS. During the loop, sort n elements. adjacent items are compared. If at any point the value on the left is greater than the value on the right, the 4. Case Study items are swapped. At the end of the first iteration, the largest number will reside at the end of the set. This section presents a realworld case study to sort In the second stage, it loops through the array in the students of Al alBayt University in Jordan by the opposite direction; starting from the item just before the university number (students IDs) in ascending order. most recently sorted item, and moving back towards the In this case study, BS, SS, shell sort, enhanced shell start of the list. Again, adjacent items are swapped if sort, ESS, and EBS algorithms are applied with 12500 required. The cocktail sort also fits in the category of as total number of students. exchange sorts due to the manner in which elements are Table 5. Execution time for the six algorithms. moved inside the array during the sorting process. As illustrated in [12], both space and time Algorithm Elapsed Time complexities of the Cocktail sort are the same as that of Bubble sort 506 ms Enhanced bubble sort 151 ms the BS for exactly the same reasons. That is, time Selection sort 346 ms complexity is O( n2), and space complexity for inplace Enhanced selection sort 307 ms sorting is O(1). EBS is more efficient and faster than Shell sort 322 ms Enhanced shell sort 249 ms both, bubble sort and Cocktail sort, since it takes O( nlgn ) time complexity while BS and cocktail sort take O( n2) to sort n elements.

An Enhancement of Major Sorting Algorithms 61

algorithms are applied on a realworld case study of sorting a database of (12500) records and the results showed that the EBS also increases the efficiency of both shell sort and enhanced shell sort algorithms.

References [1] Aho A., Hopcroft J., and Ullman J., The Design and Analysis of Computer Algorithms , Addison Wesley, 1974. [2] Astrachanm O., Bubble Sort: An Archaeological Algorithmic Analysis , Duk University, 2003. [3] Bell D., “The Principles of Sorting,” Computer Journal of the Association for Computing

Figure 1. The interface of the sorting application. Machinery , vol. 1, no. 2, pp. 7177, 1958. [4] Box R. and Lacey S. , “A Fast Easy Sort,” The simulator was built using Visual C++ to deal Computer Journal of Byte Magazine , vol. 16, with the database and to sort its records. The interface no. 4, pp. 315315, 1991. of this simulator is shown in Figure 1. [5] Cormen T., Leiserson C., Rivest R., and Stein The elapsed time for sorting the database is C., Introduction to Algorithms , McGraw Hill, measured using the (clock()) function of C++ and 2001. recorded for each algorithm, as shown in Table 5. [6] Deitel H. and Deitel P., C++ How to Program , Figure 2 shows a comparison of the elapsed time in Prentice Hall, 2001. milliseconds of the BS, EBS, SS, and ESS. [7] Friend E., “Sorting on Electronic Computer Systems,” Computer Journal of ACM , vol. 3,

600 no. 2, pp. 134168, 1956. [8] Knuth D., The Art of Computer Programming , 500 Addison Wesley, 1998. 400 Bubble Sort [9] Kruse R., and Ryba A., Data Structures and Enhanced Bubble Sort 300 Program Design in C++ , Prentice Hall, 1999. Selection Sort 200 Enhanced Selection Sort [10] Ledley R., Programming and Utilizing Digital Computers , McGraw Hill, 1962. 100 [11] Levitin A., Introduction to the Design and 0 Sorting Techniques Analysis of Algorithms , Addison Wesley, 2007. [12] Nyhoff L., An Introduction to Data Structures , Figure 2. Comparison of sorting techniques. Nyhoff Publishers, Amsterdam, 2005. From Figure 2, it is apparent that the ESS relatively [13] Organick E., A FORTRAN Primer , Addison increases the efficiency of the selection sort and EBS Wesley, 1963. speeds up the bubble sort and enhances its efficiency. [14] Pratt V., and Sorting Networks , Garland Publishers, 1979. [15] Sedgewick R., “Analysis of Shellsort and 5. Conclusions Related Algorithms,” in Proceedings of the 4th In this paper, two new sorting algorithms are presented. Annual European Symposium on Algorithms , ESS has O( n2) complexity, but it is faster than SS, pp. 111, 1996. especially if the input array is stored in secondary [16] Seward H., “Information Sorting in the memory, since it performs less number of swap Application of Electronic Digital Computers to operations. Business Operations,” Masters Thesis , 1954. SS can be specially implemented to be stable. One [17] Shahzad B. and Afzal M., “Enhanced Shell way of doing this is to artificially extend the key Sorting Algorithm,” Computer Journal of comparison, so that comparisons between two objects Enformatika , vol. 21, no. 6, pp. 6670, 2007. with other equal keys are decided using the order of the [18] Shell D., “A High Speed Sorting Procedure,” entries in the original data order as a tiebreaker. ESS is Computer Journal of Communications of the stable without the need to this special implementation. ACM , vol. 2, no. 7, pp. 3032, 1959. EBS is definitely faster than BS, since BS performs [19] Thorup M., “Randomized Sorting in O(n log log O( n2) operations but EBS performs O( nlgn ) operations n) Time and Linear Space Using Addition, to sort n elements. Furthermore, the proposed Shift, and Bit Wise Boolean Operations,” algorithms are compared with some recent sorting Computer Journal of Algorithms , vol. 42, no. 2, algorithms; shell sort and enhanced shell sort. These pp. 205230, 2002.

62 The International Arab Journal of Information Technology, Vol. 7, No. 1, January 2010

[20] Weiss M., Data Structures and Problem Solving Rami Mansi obtained his BSc in Using Java , Addison Wesley, 2002. information technology with a major in software engineering from Jehad Alnihoud received his PhD of Philadelphia University, 2006. His computer science from University research interests include computer Putra Malaysia in 2004. Currently, he graphics, algorithms design and is an assistant professor at the analysis, HCI, programming, and Faculty of Information Technology text processing. in Al alBayt University in Jordan. His research areas include image retrieval and indexing, image processing, algorithms, GIS, and computer graphics.