Modification in Sieve Sort - CiteSeerX

22 downloads 0 Views 43KB Size Report
There are number of sorting algorithms in the present day world. Insertion sort takes O(n2). Merge sort has a better asymptotic running time, O(n lg n) both in the ...
Modification in Sieve Sort Varun Jain

Dr.Suneeta Agarwal

Department of Computer science and Engineering Motilal Nehru National Institute of Technology Allahabad-211004,Utter Pradesh,India Phone no +91983994288;Fax:+91532-2445101;

Department of Computer science and Engineering

[email protected]

[email protected]

Motilal Nehru National Institute of Technology Allahabad-211004,Utter Pradesh,India Phone no +919235880561;Fax:+91532-2445101;

ABSTRACT

2. SIEVE SORT [1]

Sorting is a well known computational problem. Sorting means arranging a set of records (or a list of keys) in some (increasing or decreasing) order. A new sorting algorithm named as Sieve Sort[1] has been claimed to be stable by the author. We have contradicted its stability through examples. Stable sorting algorithms maintain the relative order of records with equal keys. We have modified the Sieve Sort[1] to make it a stable sorting algorithm. We have also proposed some modifications in the said algorithm to make it faster.

Sieve sort [1] rearranges the elements of the given list by sieving them in an appropriate fashion. The worst case and best case running times of this algorithm are shown to be O(n2) and O(n), respectively, where n is the number of records in the given list. Also, this algorithm has been claimed by the author to be stable. It works as: First pass: Let A = {a1, a2, … an} be the given list of elements. A header list H[ ] of maximum size n is used. Each element of H has a list associated with it. H[1] First element a1.is stored in H[1] Second element a2 is attached in the list with this header node H[1] only if the value of a2 is less than the value of a1. Otherwise, header list is appended by adding one more header node i.e H[2] where a2 is stored.

Keywords Algorithm, stack, stable sorting.

1. INTRODUCTION

All the elements of A are divided in p(for some p) subsequences led by p header nodes H[1] through H[p], where 1 < i