Topic > Data structure and algorithms: sorting and searching...

Sort and search techniques.INTRODUCTIONSort is the process of rearranging the provided objects into a specific order. It is done in a way that serves the purpose of the research. Objects (data) stored anywhere like in libraries, hospitals, warehouses, institutes and different databases need to be searched and retrieved. So, in order for data to be retrieved easily and in a more understandable form, it is important that such data is sorted. There are many sorting techniques of which three are the ones we will talk about: Shell Sort. Bucket Sort. Radix Sort. HOW IT WORKS Shell Sort This sorting algorithm essentially uses insertion sort to solve the problem. Breaks the problem down into smaller parts. Table 1: Index0 1 2 3 4 5 6 7 8 9 Table 2: Array40 80 35 75 60 57 34 90 70 45 There is this gap value in shell sort which starts like: Gap value = ( length of array/2) = 10/2 = 5Now we will select the subarrays using the gap value. From index 0 and after the gap of 5 from this index we will be at index 5 and if we go after the gap of 5 again we will be at index 10 since there is no index no. 10 we have two indices 0 and 5 so we will have a subarray [40, 57] and similarly now we will start with index n. 1 and we will repeat the process. In the end we will have the subarrays [40, 57], [34, 80], [35, 90], [75, 70] and [60, 45]. Now we will have to use insertion sort on each subarray and if they are unsorted we will swap them into their indices.40 34 35 70 45 57 80 90 75 60Now we will take the gap value and simplify it further so we can have more gap values small. So we will take the previous gap value and divide it by 2. Gap value = 5/2 = 2.5 = 2Now using this gap value we will have subarrays [40...... half of the sheet..... . algorithm is:O(kn)Where k = no. of digits in the longest entered number en = no. of input.PROS & CONSShell SortPro: It is efficient when the array list is medium size. It is more complex than insertion sort. Relatively simple to implement. Cons: Poses some very difficult mathematical problems, many of which have not been solved. It is not yet known which choice increases the best results. It is a rather complex sorting algorithm. Bucket SortPro: This is useful for rough sorting. It's fast. It's easy to implement. Cons: Does not do in-place sorting. Radix SortPro: Does not perform comparisons on individual elements. It is fast. It is easy to implement. Cons: Not a good choice for floating point numbers. Not good for arbitrary strings. Not order on site.