SlideShare a Scribd company logo
Hari Krishna Gurram & Gera Jaideep
International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 55
Index Sort
Hari Krishna Gurram harikrishna553@gmail.com
M.Tech (CS),
Ucek, JNTU Kakinada.
Gera Jaideep jaideep.gera@gmail.com
M.Tech(CS),
Ucek, JNTU Kakinada.
Abstract
One of the fundamental issues in computer science is ordering a list of items. Although there is a 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 a new sorting algorithm (Index
Sort) which runs based on the previously sorted elements.. This algorithm was analyzed, implemented
and tested and the results are promising for a random data.
Keywords: Index Sort, Binary Search, Position.
1. INTRODUCTION
Today real world getting tremendous amounts of data from various sources like data warehouse, data
marts etc. To search for particular information we need to arrange this data in a sensible order. Many
years ago, it was estimated that more than half the time on commercial computers was spent in sorting.
Fortunately variety of sorting algorithms came into existence with different techniques [1].
Many algorithms are well known for sorting the unordered lists. Most important of them are merge sort,
heap sort, shell sort and quick sort etc. [2]. As stated in [3], sorting has been considered as a
fundamental problem in the study of algorithms, that due to many reasons:
The need to sort the information is inherent in many applications.
Algorithms often use sorting as a key subroutine.
Many engineering issues come to the fore when implementing sorting algorithms.
In algorithm design, there are many essential techniques represented in the body of sorting
algorithms.
Sorting algorithms plays a vital role in various indexing techniques used in data warehousing, and daily
transactions in online Transactionalprocessing (OLTP). Efficient sorting is important to optimize the use of
other sorting algorithms that require sorted lists correctly.
Sorting algorithms can be classified by:
1. Computational complexity (best, average and worst behavior) of element comparisons in
terms list size n. For a typical sorting algorithm best case, average case and worst case is
O(n log n), example merge sort.
2. Number of swaps
3. Stability : A sorting algorithm is stable if whenever there are two records X and Y, with the
same key and X appearing before Y in original list, X will be appear before Y in the sorted list.
4. Usage of memory
In this paper, a new sorting algorithm (Index sort) is proposed; here the basic idea is first we are
going to sort the 2 elements and these 2 elements acts as an index to next 4 elements to sort, so
totally 6 elements sorted, next these 6 elements are used as an index to sort 12 elements so
totally 18 elements sorted, this process continues until all elements are sorted.
Hari Krishna Gurram & Gera Jaideep
International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 56
Section 2 presents the concept of Index sorting algorithm and its pseudo code. Section 3 shows the
implementation results for various sizes of input. Finally, the conclusion was presented in section 4.
2. INDEX SORT
2.1 Concept
The main logic presented here is initially we sort forst two elements in the given input. An index is created
by using these two elements which is used to sort twice the elements in the index, i.e., if index has ‘n’
number of elements, then ‘2n’ elements are sorted by this index. This process repeated until all the
elements sorted. To get better results we are using binary search to search for the position of the
element.
2.2 Pseudocode
functionindexSort( input, noEle )
1. initialSort(input)
2. varnoEle := 2
3. sort( input, noEle )
4. end indexSort
Line 1 of indexSort(input, noEle ), calls the method initialSort(input), which sort the first two
elements
in the given input. The pseudo code for initialSort(input) is given below.
functioninitialSort(input)
Sort the first two elements in the given input.
endinitialSort
Line 2 of indexSort( input, noEle ), calls the sort method which sort the remaining all elements by
using this index. The pseudo code for sort method is given below.
Global variables:
var length := input.length
var flag := 0
var position
function sort( input, noEle)
1. Node index[noEle]
2. copyFromArrayToNode( input, index, noEle )
3. varsortPos := 3*noEle
4. var length1 := index.length
5. if( sortPos>len )
6. sortPos := len
7. flag := 1
8. end if
9. for i in noEle to sortPos
10. if ( input[i] < index[1].element )
11. position := 1
12. else if ( input[i] > index[len].element )
13. position := len
14. else
15. Position := binarySearch( index, 1, len, input[i] )
16. once the position is found, then compare the element input[i] with the
index[position] and place input[i] in proper place by making single linked list,
since index[] is of type Node.
17. end LOOP
18. copyFromNodeToArray( index, input )
19. If ( flag = 0 )
20. Sort( input, sortPos )
Hari Krishna Gurram & Gera Jaideep
International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 57
Line 1 of sort( input, noEle) creats an array index of type Node, Node is of structure type, the definition of
Node is given below.
Struct Node
int element
Node next
end Node
Line 2 of sort( input, noEle) calls the method copyFromArrayToNode( input, index, noEle ), this method
creates an index which is used to sort the elements in the given input, the index is created by using first
‘noEle’ elements of the input array. The pseudo code for copyFromArrayToNode( input, index, noEle ) is
given below.
functioncopyFromArrayToNode( input, index, noEle )
1. for i 1 to noEle
2. in[i].element := input[i]
3. In[i].next := NULL
4. end LOOP
5. end copyFromArrayToNode
Line 4 of sort method has below type of declaration:
var length1 := index.length
hereindex.length returns the length of the array index, then this value is assigned to length1, same case
for global variable length.
Lines 5 -8 has a condition, which checks when to stop the sorting procedure, and limit the number of
elements to the size of given input data.
Lines 9-17 sorts the given elements from noEle to 3*noEle, since all the elements uptonoEle in the input
array are already sorted, so by using this as index, 2*noEle elements of input array are sorted. To make
this algorithm efficient we are using binary search to find out the position of the given input element in the
index.
The pseudocode for binarySearch is given below.
functionbinarySearch( Node array[], var low, var high, var element )
1. find the position such that element is greater than or equal to array[position] and less
than array[position+1].
2. return position
3. endbinarySearch.
Line 18 of sort method calls copyFromNodeToArraymethod which copy the sorted elements in the index
to the input array, the pseudo code for copyFromNodeToArray is given below.
Function copyFromNodeToArray( Node in[], var input[] )
1. var length := in.length
2. var count := 1
3. for I in 1 to length
4. while ( in[i] != NULL )
5. Input[count] := in[i].element
6. count := count +1
7. In[i] := in[i].next
8. end LOOP
9. end LOOP
10. end copyFromNodeToArray
Line 20 calls the sort method recursively unti all the elements in the given array are sorted.
The index creation and the number of elements sorted by this index are explained by using the below
table.
Hari Krishna Gurram & Gera Jaideep
International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 58
S.No Index created by
number of elements
Number of elements
sorted by using the
index
Total sorted elements
1 2 4 6
2 6 12 18
3 18 36 54
4 54 108 162
5 162 324 486
6 486 972 1458
7 1458 2916 4374
8 4374 8748 13122
9 13122 26244 39366
10 39366 78732 118098
11 118098 236198 354294
12 354294 708588 1062882
13 1062882 2125764 3188646
14 3188646 6399292 9564938
15 9565938 10434062 ( Actually the
valu is 19131876 but I t
exceeded the input size
2 chrore )
20000000
TABLE 1: Shows how the index is created and elements are sorting.
3. IMPLEMENTATION RESULTS
Below graphs shows the implementation results of Index Sort.
FIGURE 1 : Sorting the random elements (Number of elements Vs Time )
Hari Krishna Gurram & Gera Jaideep
International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 59
FIGURE 2 : Sorting the random elements (Number of elements Vs Comparisons )
FIGURE 3: Sorting the reversely sorted elements (Number of elements VsTime )
Hari Krishna Gurram & Gera Jaideep
International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 60
FIGURE 4: Sorting the reversely sorted elements (Number of elements VsComparisons )
When elements are in normal sorte order ( i.e. not reverse sorted ), then this algorithm has time
complexity of O(n*n), when elements are in reverse sorted order then this algorithm works in best case.
4. CONCLUSION
The index sorting algorithm sort the elements by creating the index recursively and sort the elements
which are in reverse order very efficiently and sort the random input also in an efficient manner. For all
random inputs of data the implementation results shows promising results.
REFERENCES
[1] Kruse R., and Ryba A., Data Structures and Program Design in C++, Prentice Hall, 1999.
[2] Shahzad B. and Afzal M., “Enhanced ShellSorting Algorithm,” Computer Journal of
Enformatika, vol. 21, no. 6, pp. 66-70, 2007.
[3] Cormen T., Leiserson C., Rivest R., and Stein C., Introduction to Algorithms, McGraw Hill, 2001.
[4] Aho A., Hopcroft J., and Ullman J., The Design and Analysis of Computer Algorithms, Addison
Wesley, 1974.
[5] Astrachanm O., Bubble Sort: An Archaeological Algorithmic Analysis, Duk University, 2003.
[6] Bell D., “The Principles of Sorting,” Computer Journal of the Association for Computing Machinery,
vol. 1, no. 2, pp. 71-77, 1958.
[7] Box R. and Lacey S., “A Fast Easy Sort,”Computer Journal of Byte Magazine, vol. 16,no. 4, pp. 315-
315, 1991.
.
[8] Deitel H. and Deitel P., C++ How to Program, Prentice Hall, 2001.
[9] Friend E., “Sorting on Electronic ComputerSystems,” Computer Journal of ACM, vol. 3,
Hari Krishna Gurram & Gera Jaideep
International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 61
no. 2, pp. 134-168, 1956.
[10] Knuth D., The Art of Computer Programming,Addison Wesley, 1998.
[11] Ledley R., Programming and Utilizing Digital Computers, McGraw Hill, 1962.
[12] Levitin A., Introduction to the Design andAnalysis of Algorithms, Addison Wesley, 2007.
[13] Nyhoff L., An Introduction to Data Structures, Nyhoff Publishers, Amsterdam, 2005.
[14] Organick E., A FORTRAN Primer, AddisonWesley, 1963.
[15] Pratt V., Shellsort and Sorting Networks,Garland Publishers, 1979.
[16] Sedgewick R., “Analysis of Shellsort andRelated Algorithms,” in Proceedings of the 4th
Annual European Symposium on Algorithms,pp. 1-11, 1996.
[17] Seward H., “Information Sorting in theApplication of Electronic Digital Computers to
Business Operations,” Masters Thesis, 1954.
[18] Shell D., “A High Speed Sorting Procedure,”Computer Journal of Communications of the ACM, vol.
2, no. 7, pp. 30-32, 1959.
[19] Thorup M., “Randomized Sorting in O(n log logn) Time and Linear Space Using Addition,Shift, and
Bit Wise Boolean Operations,”Computer Journal of Algorithms, vol. 42, no. 2,pp. 205-230, 2002.

More Related Content

PDF
Average sort
Waqas Tariq
 
PDF
IRJET- A Survey on Different Searching Algorithms
IRJET Journal
 
PDF
Introduction to Data Structure
Prof Ansari
 
PDF
Data Structures (BE)
PRABHAHARAN429
 
PDF
Distance Sort
Waqas Tariq
 
PDF
ODD EVEN BASED BINARY SEARCH
IAEME Publication
 
PDF
SQUARE ROOT SORTING ALGORITHM
MirOmranudinAbhar
 
PPTX
Data Structures (CS8391)
Elavarasi K
 
Average sort
Waqas Tariq
 
IRJET- A Survey on Different Searching Algorithms
IRJET Journal
 
Introduction to Data Structure
Prof Ansari
 
Data Structures (BE)
PRABHAHARAN429
 
Distance Sort
Waqas Tariq
 
ODD EVEN BASED BINARY SEARCH
IAEME Publication
 
SQUARE ROOT SORTING ALGORITHM
MirOmranudinAbhar
 
Data Structures (CS8391)
Elavarasi K
 

What's hot (20)

PPT
L10 sorting-searching
mondalakash2012
 
PDF
Ijcse13 05-01-048
vital vital
 
PDF
Data structure ppt
Prof. Dr. K. Adisesha
 
PPTX
Data structures and algorithms
Hoang Nguyen
 
PDF
Data Structures & Algorithm design using C
Emertxe Information Technologies Pvt Ltd
 
PDF
Alternate Sort
IOSR Journals
 
PPTX
Set data structure
Tech_MX
 
PPT
Data structures
Manaswi Sharma
 
DOCX
Top 50 oracle interview questions and answers
NIKUL GOYAL
 
PPTX
Data structures
Sneha Chopra
 
PDF
LectureNotes-03-DSA
Haitham El-Ghareeb
 
PPTX
Data structure &amp; algorithms introduction
Sugandh Wafai
 
PDF
Datastructure
Griffinder VinHai
 
PPT
Data structures using c
Prof. Dr. K. Adisesha
 
PDF
LectureNotes-06-DSA
Haitham El-Ghareeb
 
PPT
Data Structures- Part3 arrays and searching algorithms
Abdullah Al-hazmy
 
PPT
Data structures using C
Prof. Dr. K. Adisesha
 
PDF
Data structures
Naresh Babu Merugu
 
PDF
Lecture-05-DSA
Haitham El-Ghareeb
 
PDF
Sorting Algorithms
Mohammed Hussein
 
L10 sorting-searching
mondalakash2012
 
Ijcse13 05-01-048
vital vital
 
Data structure ppt
Prof. Dr. K. Adisesha
 
Data structures and algorithms
Hoang Nguyen
 
Data Structures & Algorithm design using C
Emertxe Information Technologies Pvt Ltd
 
Alternate Sort
IOSR Journals
 
Set data structure
Tech_MX
 
Data structures
Manaswi Sharma
 
Top 50 oracle interview questions and answers
NIKUL GOYAL
 
Data structures
Sneha Chopra
 
LectureNotes-03-DSA
Haitham El-Ghareeb
 
Data structure &amp; algorithms introduction
Sugandh Wafai
 
Datastructure
Griffinder VinHai
 
Data structures using c
Prof. Dr. K. Adisesha
 
LectureNotes-06-DSA
Haitham El-Ghareeb
 
Data Structures- Part3 arrays and searching algorithms
Abdullah Al-hazmy
 
Data structures using C
Prof. Dr. K. Adisesha
 
Data structures
Naresh Babu Merugu
 
Lecture-05-DSA
Haitham El-Ghareeb
 
Sorting Algorithms
Mohammed Hussein
 
Ad

Similar to INDEX SORT (20)

PPTX
my docoment
NeeshanYonzan
 
PPTX
Searching and Sorting Algorithms in Data Structures
poongothai11
 
PPTX
Chapter 2 Sorting and Searching .pptx.soft
kuruabeje7
 
PPT
Chapter 3 - Elementary Searching and Sorting Algorithms.ppt
AbdisaAwel
 
PDF
GRID SEARCHING Novel way of Searching 2D Array
Editor IJCATR
 
PPTX
Algorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Pratik Parmar
 
PPT
9 Arrays
Praveen M Jigajinni
 
PPT
Algorithms with-java-advanced-1.0
BG Java EE Course
 
PPTX
21CS32 DS Module 1 PPT.pptx
reddy19841
 
PPTX
Chapter 3 - Data Structure and Algorithms.pptx
tarrebulehora
 
PPTX
Data structure chapter 2 Time complexity of known algorithms.pptx
fikadumeuedu
 
PPTX
Arrays And Pointers in C programming language
Jasminelobo2
 
PPTX
Various Operations Of Array(Data Structure Algorithm).pptx
atirathpal007
 
PPTX
Chapter3.pptx
ASMAALWADEE2
 
PPTX
data structures and algorithms Unit 3
infanciaj
 
PPTX
CSE 443 (1).pptx
JayaKrishna636858
 
PDF
Comparative Performance Analysis & Complexity of Different Sorting Algorithm
paperpublications3
 
PDF
CP PPT_Unit IV computer programming in c.pdf
saneshgamerz
 
PDF
PROPOSAL OF A TWO WAY SORTING ALGORITHM AND PERFORMANCE COMPARISON WITH EXIST...
IJCSEA Journal
 
PDF
Data Structures Design Notes.pdf
AmuthachenthiruK
 
my docoment
NeeshanYonzan
 
Searching and Sorting Algorithms in Data Structures
poongothai11
 
Chapter 2 Sorting and Searching .pptx.soft
kuruabeje7
 
Chapter 3 - Elementary Searching and Sorting Algorithms.ppt
AbdisaAwel
 
GRID SEARCHING Novel way of Searching 2D Array
Editor IJCATR
 
Algorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Pratik Parmar
 
Algorithms with-java-advanced-1.0
BG Java EE Course
 
21CS32 DS Module 1 PPT.pptx
reddy19841
 
Chapter 3 - Data Structure and Algorithms.pptx
tarrebulehora
 
Data structure chapter 2 Time complexity of known algorithms.pptx
fikadumeuedu
 
Arrays And Pointers in C programming language
Jasminelobo2
 
Various Operations Of Array(Data Structure Algorithm).pptx
atirathpal007
 
Chapter3.pptx
ASMAALWADEE2
 
data structures and algorithms Unit 3
infanciaj
 
CSE 443 (1).pptx
JayaKrishna636858
 
Comparative Performance Analysis & Complexity of Different Sorting Algorithm
paperpublications3
 
CP PPT_Unit IV computer programming in c.pdf
saneshgamerz
 
PROPOSAL OF A TWO WAY SORTING ALGORITHM AND PERFORMANCE COMPARISON WITH EXIST...
IJCSEA Journal
 
Data Structures Design Notes.pdf
AmuthachenthiruK
 
Ad

More from Waqas Tariq (20)

PDF
The Use of Java Swing’s Components to Develop a Widget
Waqas Tariq
 
PDF
3D Human Hand Posture Reconstruction Using a Single 2D Image
Waqas Tariq
 
PDF
Camera as Mouse and Keyboard for Handicap Person with Troubleshooting Ability...
Waqas Tariq
 
PDF
A Proposed Web Accessibility Framework for the Arab Disabled
Waqas Tariq
 
PDF
Real Time Blinking Detection Based on Gabor Filter
Waqas Tariq
 
PDF
Computer Input with Human Eyes-Only Using Two Purkinje Images Which Works in ...
Waqas Tariq
 
PDF
Toward a More Robust Usability concept with Perceived Enjoyment in the contex...
Waqas Tariq
 
PDF
Collaborative Learning of Organisational Knolwedge
Waqas Tariq
 
PDF
A PNML extension for the HCI design
Waqas Tariq
 
PDF
Development of Sign Signal Translation System Based on Altera’s FPGA DE2 Board
Waqas Tariq
 
PDF
An overview on Advanced Research Works on Brain-Computer Interface
Waqas Tariq
 
PDF
Exploring the Relationship Between Mobile Phone and Senior Citizens: A Malays...
Waqas Tariq
 
PDF
Principles of Good Screen Design in Websites
Waqas Tariq
 
PDF
Progress of Virtual Teams in Albania
Waqas Tariq
 
PDF
Cognitive Approach Towards the Maintenance of Web-Sites Through Quality Evalu...
Waqas Tariq
 
PDF
USEFul: A Framework to Mainstream Web Site Usability through Automated Evalua...
Waqas Tariq
 
PDF
Robot Arm Utilized Having Meal Support System Based on Computer Input by Huma...
Waqas Tariq
 
PDF
Dynamic Construction of Telugu Speech Corpus for Voice Enabled Text Editor
Waqas Tariq
 
PDF
An Improved Approach for Word Ambiguity Removal
Waqas Tariq
 
PDF
Parameters Optimization for Improving ASR Performance in Adverse Real World N...
Waqas Tariq
 
The Use of Java Swing’s Components to Develop a Widget
Waqas Tariq
 
3D Human Hand Posture Reconstruction Using a Single 2D Image
Waqas Tariq
 
Camera as Mouse and Keyboard for Handicap Person with Troubleshooting Ability...
Waqas Tariq
 
A Proposed Web Accessibility Framework for the Arab Disabled
Waqas Tariq
 
Real Time Blinking Detection Based on Gabor Filter
Waqas Tariq
 
Computer Input with Human Eyes-Only Using Two Purkinje Images Which Works in ...
Waqas Tariq
 
Toward a More Robust Usability concept with Perceived Enjoyment in the contex...
Waqas Tariq
 
Collaborative Learning of Organisational Knolwedge
Waqas Tariq
 
A PNML extension for the HCI design
Waqas Tariq
 
Development of Sign Signal Translation System Based on Altera’s FPGA DE2 Board
Waqas Tariq
 
An overview on Advanced Research Works on Brain-Computer Interface
Waqas Tariq
 
Exploring the Relationship Between Mobile Phone and Senior Citizens: A Malays...
Waqas Tariq
 
Principles of Good Screen Design in Websites
Waqas Tariq
 
Progress of Virtual Teams in Albania
Waqas Tariq
 
Cognitive Approach Towards the Maintenance of Web-Sites Through Quality Evalu...
Waqas Tariq
 
USEFul: A Framework to Mainstream Web Site Usability through Automated Evalua...
Waqas Tariq
 
Robot Arm Utilized Having Meal Support System Based on Computer Input by Huma...
Waqas Tariq
 
Dynamic Construction of Telugu Speech Corpus for Voice Enabled Text Editor
Waqas Tariq
 
An Improved Approach for Word Ambiguity Removal
Waqas Tariq
 
Parameters Optimization for Improving ASR Performance in Adverse Real World N...
Waqas Tariq
 

Recently uploaded (20)

PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PDF
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Landforms and landscapes data surprise preview
jpinnuck
 

INDEX SORT

  • 1. Hari Krishna Gurram & Gera Jaideep International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 55 Index Sort Hari Krishna Gurram [email protected] M.Tech (CS), Ucek, JNTU Kakinada. Gera Jaideep [email protected] M.Tech(CS), Ucek, JNTU Kakinada. Abstract One of the fundamental issues in computer science is ordering a list of items. Although there is a 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 a new sorting algorithm (Index Sort) which runs based on the previously sorted elements.. This algorithm was analyzed, implemented and tested and the results are promising for a random data. Keywords: Index Sort, Binary Search, Position. 1. INTRODUCTION Today real world getting tremendous amounts of data from various sources like data warehouse, data marts etc. To search for particular information we need to arrange this data in a sensible order. Many years ago, it was estimated that more than half the time on commercial computers was spent in sorting. Fortunately variety of sorting algorithms came into existence with different techniques [1]. Many algorithms are well known for sorting the unordered lists. Most important of them are merge sort, heap sort, shell sort and quick sort etc. [2]. As stated in [3], sorting has been considered as a fundamental problem in the study of algorithms, that due to many reasons: The need to sort the information is inherent in many applications. Algorithms often use sorting as a key subroutine. Many engineering issues come to the fore when implementing sorting algorithms. In algorithm design, there are many essential techniques represented in the body of sorting algorithms. Sorting algorithms plays a vital role in various indexing techniques used in data warehousing, and daily transactions in online Transactionalprocessing (OLTP). Efficient sorting is important to optimize the use of other sorting algorithms that require sorted lists correctly. Sorting algorithms can be classified by: 1. Computational complexity (best, average and worst behavior) of element comparisons in terms list size n. For a typical sorting algorithm best case, average case and worst case is O(n log n), example merge sort. 2. Number of swaps 3. Stability : A sorting algorithm is stable if whenever there are two records X and Y, with the same key and X appearing before Y in original list, X will be appear before Y in the sorted list. 4. Usage of memory In this paper, a new sorting algorithm (Index sort) is proposed; here the basic idea is first we are going to sort the 2 elements and these 2 elements acts as an index to next 4 elements to sort, so totally 6 elements sorted, next these 6 elements are used as an index to sort 12 elements so totally 18 elements sorted, this process continues until all elements are sorted.
  • 2. Hari Krishna Gurram & Gera Jaideep International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 56 Section 2 presents the concept of Index sorting algorithm and its pseudo code. Section 3 shows the implementation results for various sizes of input. Finally, the conclusion was presented in section 4. 2. INDEX SORT 2.1 Concept The main logic presented here is initially we sort forst two elements in the given input. An index is created by using these two elements which is used to sort twice the elements in the index, i.e., if index has ‘n’ number of elements, then ‘2n’ elements are sorted by this index. This process repeated until all the elements sorted. To get better results we are using binary search to search for the position of the element. 2.2 Pseudocode functionindexSort( input, noEle ) 1. initialSort(input) 2. varnoEle := 2 3. sort( input, noEle ) 4. end indexSort Line 1 of indexSort(input, noEle ), calls the method initialSort(input), which sort the first two elements in the given input. The pseudo code for initialSort(input) is given below. functioninitialSort(input) Sort the first two elements in the given input. endinitialSort Line 2 of indexSort( input, noEle ), calls the sort method which sort the remaining all elements by using this index. The pseudo code for sort method is given below. Global variables: var length := input.length var flag := 0 var position function sort( input, noEle) 1. Node index[noEle] 2. copyFromArrayToNode( input, index, noEle ) 3. varsortPos := 3*noEle 4. var length1 := index.length 5. if( sortPos>len ) 6. sortPos := len 7. flag := 1 8. end if 9. for i in noEle to sortPos 10. if ( input[i] < index[1].element ) 11. position := 1 12. else if ( input[i] > index[len].element ) 13. position := len 14. else 15. Position := binarySearch( index, 1, len, input[i] ) 16. once the position is found, then compare the element input[i] with the index[position] and place input[i] in proper place by making single linked list, since index[] is of type Node. 17. end LOOP 18. copyFromNodeToArray( index, input ) 19. If ( flag = 0 ) 20. Sort( input, sortPos )
  • 3. Hari Krishna Gurram & Gera Jaideep International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 57 Line 1 of sort( input, noEle) creats an array index of type Node, Node is of structure type, the definition of Node is given below. Struct Node int element Node next end Node Line 2 of sort( input, noEle) calls the method copyFromArrayToNode( input, index, noEle ), this method creates an index which is used to sort the elements in the given input, the index is created by using first ‘noEle’ elements of the input array. The pseudo code for copyFromArrayToNode( input, index, noEle ) is given below. functioncopyFromArrayToNode( input, index, noEle ) 1. for i 1 to noEle 2. in[i].element := input[i] 3. In[i].next := NULL 4. end LOOP 5. end copyFromArrayToNode Line 4 of sort method has below type of declaration: var length1 := index.length hereindex.length returns the length of the array index, then this value is assigned to length1, same case for global variable length. Lines 5 -8 has a condition, which checks when to stop the sorting procedure, and limit the number of elements to the size of given input data. Lines 9-17 sorts the given elements from noEle to 3*noEle, since all the elements uptonoEle in the input array are already sorted, so by using this as index, 2*noEle elements of input array are sorted. To make this algorithm efficient we are using binary search to find out the position of the given input element in the index. The pseudocode for binarySearch is given below. functionbinarySearch( Node array[], var low, var high, var element ) 1. find the position such that element is greater than or equal to array[position] and less than array[position+1]. 2. return position 3. endbinarySearch. Line 18 of sort method calls copyFromNodeToArraymethod which copy the sorted elements in the index to the input array, the pseudo code for copyFromNodeToArray is given below. Function copyFromNodeToArray( Node in[], var input[] ) 1. var length := in.length 2. var count := 1 3. for I in 1 to length 4. while ( in[i] != NULL ) 5. Input[count] := in[i].element 6. count := count +1 7. In[i] := in[i].next 8. end LOOP 9. end LOOP 10. end copyFromNodeToArray Line 20 calls the sort method recursively unti all the elements in the given array are sorted. The index creation and the number of elements sorted by this index are explained by using the below table.
  • 4. Hari Krishna Gurram & Gera Jaideep International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 58 S.No Index created by number of elements Number of elements sorted by using the index Total sorted elements 1 2 4 6 2 6 12 18 3 18 36 54 4 54 108 162 5 162 324 486 6 486 972 1458 7 1458 2916 4374 8 4374 8748 13122 9 13122 26244 39366 10 39366 78732 118098 11 118098 236198 354294 12 354294 708588 1062882 13 1062882 2125764 3188646 14 3188646 6399292 9564938 15 9565938 10434062 ( Actually the valu is 19131876 but I t exceeded the input size 2 chrore ) 20000000 TABLE 1: Shows how the index is created and elements are sorting. 3. IMPLEMENTATION RESULTS Below graphs shows the implementation results of Index Sort. FIGURE 1 : Sorting the random elements (Number of elements Vs Time )
  • 5. Hari Krishna Gurram & Gera Jaideep International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 59 FIGURE 2 : Sorting the random elements (Number of elements Vs Comparisons ) FIGURE 3: Sorting the reversely sorted elements (Number of elements VsTime )
  • 6. Hari Krishna Gurram & Gera Jaideep International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 60 FIGURE 4: Sorting the reversely sorted elements (Number of elements VsComparisons ) When elements are in normal sorte order ( i.e. not reverse sorted ), then this algorithm has time complexity of O(n*n), when elements are in reverse sorted order then this algorithm works in best case. 4. CONCLUSION The index sorting algorithm sort the elements by creating the index recursively and sort the elements which are in reverse order very efficiently and sort the random input also in an efficient manner. For all random inputs of data the implementation results shows promising results. REFERENCES [1] Kruse R., and Ryba A., Data Structures and Program Design in C++, Prentice Hall, 1999. [2] Shahzad B. and Afzal M., “Enhanced ShellSorting Algorithm,” Computer Journal of Enformatika, vol. 21, no. 6, pp. 66-70, 2007. [3] Cormen T., Leiserson C., Rivest R., and Stein C., Introduction to Algorithms, McGraw Hill, 2001. [4] Aho A., Hopcroft J., and Ullman J., The Design and Analysis of Computer Algorithms, Addison Wesley, 1974. [5] Astrachanm O., Bubble Sort: An Archaeological Algorithmic Analysis, Duk University, 2003. [6] Bell D., “The Principles of Sorting,” Computer Journal of the Association for Computing Machinery, vol. 1, no. 2, pp. 71-77, 1958. [7] Box R. and Lacey S., “A Fast Easy Sort,”Computer Journal of Byte Magazine, vol. 16,no. 4, pp. 315- 315, 1991. . [8] Deitel H. and Deitel P., C++ How to Program, Prentice Hall, 2001. [9] Friend E., “Sorting on Electronic ComputerSystems,” Computer Journal of ACM, vol. 3,
  • 7. Hari Krishna Gurram & Gera Jaideep International Journal of Experimental Algorithms (IJEA), Volume (2) : Issue (2) : 2011 61 no. 2, pp. 134-168, 1956. [10] Knuth D., The Art of Computer Programming,Addison Wesley, 1998. [11] Ledley R., Programming and Utilizing Digital Computers, McGraw Hill, 1962. [12] Levitin A., Introduction to the Design andAnalysis of Algorithms, Addison Wesley, 2007. [13] Nyhoff L., An Introduction to Data Structures, Nyhoff Publishers, Amsterdam, 2005. [14] Organick E., A FORTRAN Primer, AddisonWesley, 1963. [15] Pratt V., Shellsort and Sorting Networks,Garland Publishers, 1979. [16] Sedgewick R., “Analysis of Shellsort andRelated Algorithms,” in Proceedings of the 4th Annual European Symposium on Algorithms,pp. 1-11, 1996. [17] Seward H., “Information Sorting in theApplication of Electronic Digital Computers to Business Operations,” Masters Thesis, 1954. [18] Shell D., “A High Speed Sorting Procedure,”Computer Journal of Communications of the ACM, vol. 2, no. 7, pp. 30-32, 1959. [19] Thorup M., “Randomized Sorting in O(n log logn) Time and Linear Space Using Addition,Shift, and Bit Wise Boolean Operations,”Computer Journal of Algorithms, vol. 42, no. 2,pp. 205-230, 2002.