Journal of Applied Sciences Research, 4(6): 760-766, 2008
© 2008, INSInet Publication
Corresponding Author: Oyelami, M.O., Department of Computer and Information Sciences, Covenant University, Ota, Ogun
State, Nigeria.
760
A Modified Diminishing Increment Sort for Overcoming the Search for
Best Sequence of Increment for Shellsort.
Oyelami, M.O.
Department of Computer and Information Sciences,
Covenant University, Ota, Ogun State, Nigeria.
Abstract: Sorting involves rearrangement of items into ascending or descending order. There are several
sorting algorithms but some are more efficient than others in terms of speed and memory utilization.
Shellsort improves on Insertion sort by decreasing the number of inversions made on the items to be
sorted. In each of its passes, it divides the list into sublists and uses insertion sort technique to sort each
sublist. The sequence of increments proposed by Shell has been found to be inefficient. Several researchers
have proposed different sequences. Although nobody has been able to determine the best possible sequence
of increments, those of Tokuda and Sedgewick have been found to be outstanding. This paper presents
a modified diminishing increment sort that overcomes the pain of looking for the best sequence of
increments. The results obtained from the experimentation of the proposed algorithm shows its better
performance over Tokuda’s and Sedgewick’s sequences of increment.
Key words: Algorithm, Sorting, Insertion Sort, Shellsort, Modified Diminishing Increment Sort, Worst-
case, Best-case and Average-case
INTRODUCTION
For computer to serve as a problem solving
machine, it must be directed on what steps to follow in
order to get the problem solved. An algorithm is a
finite sequence of instructions, each of which has a
clear meaning and can be performed with a finite
amount of effort in a finite amount of time .
[1]
Algorithms are paramount in computer programming.
An algorithm could be of no use even though it is
correct and gives a desired output if the resources like
time and storage it needs to run to completion are
intolerable.
To say that a problem is solvable algorithmically
means, informally, that a computer program can be
written that will produce the correct answer for any
input if we let it run long enough and allow it as much
storage space as it needs .
[2]
In an algorithm, instructions can be executed any
number of times, provided the instructions themselves
indicate repetition. However, no matter what the input
values may be, an algorithm terminates after executing
a finite number of instructions. Thus, a program is an
algorithm as long as it never enters an infinite loop on
any input .
[2]
An algorithm can either be correct or incorrect. A
correct algorithm is one that halts with a correct output
while an incorrect algorithm halts with an incorrect
output or may not halt at all. An algorithm has five
important features :
[3]
C Finiteness: An algorithm must always terminate
after a finite number of steps;
C Definiteness: Each step of an algorithm must be
precisely defined; the actions to be carried out
must be rigorously specified for each case;
C Input: An algorithm has zero or more inputs-
quantities that are given to it initially before the
algorithm begins, or dynamically as the algorithm
runs. These inputs are taken from specified sets
of objects;
C Output: An algorithm has one or more outputs-
quantities that have a specified relation to inputs;
C Effectiveness: An algorithm is also generally
expected to be effective, in the sense that its
operations must all be sufficiently basic that they
can in principle be done exactly and in a finite
length of time by someone using pencil and paper.
An algorithm can be described using a computer
language. It can also be specified using pseudocode.
Pseudocode provides an alternative step between an
English language description of an algorithm and an
implementation of this algorithm in a programming