The most important attribute of a Bprogram/algorithm is correctness. An algorithm that does not give a correct
output is useless. Correct algorithms may also be of little use. This often happens when the algorithm/program takes too much time than expected by the user to run or when it uses too much memory space than is available on the computer i. Identify one or more key operations and determine the number of times they are performed;
ii. Determine the total number of
Performance of a program or an algorithm is the amount of time and computer memory needed to run the program/algorithm. Two methods are normally employed in analyzing an algorithm: Analytical method Experimental method
In analytical method, the factors the time and space requirements of a program depend on are identified and their contributions are determined. But since some of these factors are not known at the time the program is written, an accurate analysis of the time and space requirements cannot be made. Experimental method deals with actually performing experiment and measuring the space and time used by the program. Two manageable approaches to estimating run time are steps executed by the program.
5.1 Worst-case, Best-case and Average-case Analysis of Sorting Algorithms
The worst-case occurs in asorting algorithm when the elements tobe sorted are in reverse order. The best-case occurs when the elements are already sorted. The average-case may occur when part of the elements are already sorted. The average-case has data randomly distributed in the list [12]. The average-case may not be easy to determine in that it may not be apparent what constitutes an ‘average’ input. Concentration is always on finding only the worst-case running time for any input of size n due to the following reasons [5]: i. The worst-case running time of an algorithm is an upper bound on the running time for any input. Knowing it gives us a guarantee that the algorithm will never take any longer. We need not make some educated guess about the running time and hope that it nevergets much worse.
5.2 Analysis of Shellsort and Improved Shellsort for the Worst-case and Best- case Scenarios
Analysis of Shellsort is very difficult and incomplete. A complete analysis is extremely difficult and requires answers to some mathematical problems that have not yet been solved [2,3]. The running time of Shellsort depends on the choice of incrementsequence and the proofs can be rather complicated. The average-case analysis is a long-standing open problem, except for the trivial increment sequences [7]. Since Shellsort improves on Insertion Sort by decreasing the number of comparisons made, the approach employed here in comparing Shellsort with this proposed algorithm is to compare the number of comparisons made in each case.