SlideShare a Scribd company logo
1 of 4
Download to read offline
D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com
ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134
www.ijera.com 131 | P a g e
A Fast Merge Sort
D.Abhyankar
D. Abhyankar, School of Computer Science, D.A. University, Indore M.P. India
Abstract
Merge sort is one of the most efficient ways to solve sorting problem. Our research suggests that it is still
responsive to clever optimizations. A considerably fast variation of Merge sort has been proposed in this paper.
Proposed algorithm uses some novel optimizations to improve the speed of the proposed algorithm. Proposed
algorithm not only applies some novel optimizations but also retains most of the old optimizations which were
effective in reducing space and time. In addition to time and space efficiency, proposed algorithm offers the
benefit of elegant design. Profiling has been carried out to verify the effectiveness of proposed algorithm.
Profiling results reinforce the fact that proposed algorithm is significantly faster than existing best algorithm.
I. Introduction
Sorting is one of the most fascinating computational problems that demands a lot of computer time in
practical applications. Merge sort is a stable divide and conquer algorithm that solves sorting efficiently. It
requires an extra array of size Θ(n) to sort and thus it is not an in-place sorting algorithm. It spends running time
Θ(n log n) to sort the input array [1]. Although a lot of research work has been carried out to improve the
performance of Merge sort [2], it is still responsive to novel optimizations. Our research offers a better
implementation of Merge sort that saves a lot of time and space. Proposed algorithm provides an extremely
compact and fast Merge function. Also, it retains the advantages of existing Merge sort variations. This Section
is followed by Section 2 that presents the proposed algorithm. Section 3 presents the comparative profiling
statistics of the proposed implementation and the existing best Merge sort. In the end, Section 4 concludes and
presents the essence of the paper.
II. Proposed Implementation
The most novel point in proposed algorithm is the amazingly clever sentinel trick accomplished by
making the recursively sorted subarrays overlap. This trick eliminates a test in the inner loop by assuring right
side of the array contains the last element. That assurance has a
cost: lengthening the first of the two recursive sorts so they overlap. It is important to observe that the trick
reduces the code size of Merge function. Actual improvement in terms of time has been assessed by profiling in
Section 3. It is important to note that proposed implementation retains the existing optimizations on Merge sort.
For instance, proposed implementation is a hybrid of Merge sort and Insertion sort. Also, the data move count
has been reduced to an extremely low level. Following C++ code formally asserts the implementation.
void Merge(int*& a, int& h, int*& buf);
void MergeSort(int* a, int n, int* b, int m);
void Copy(int* s, int n, int* d);
void InsertionSort(int* a, int n);
void Sort(int* a, int n)
{
if(n > 5)
{
int h = (n+1)/2;
int* b = new int[h+1];
MergeSort(b,h+1,a,1);
a[h]=b[h];
MergeSort(&a[h],n-h,a,0);
Merge(a,h,b);
delete[] b;
}
else{
RESEARCH ARTICLE OPEN ACCESS
D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com
ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134
www.ijera.com 132 | P a g e
InsertionSort(a,n);
}
}
void MergeSort(int* a, int n, int* b, int m)
{
if(n > 5)
{
int h = (n/2);
MergeSort(b,h+1,a,m+1);
a[h]=b[h];
MergeSort(&a[h],n-h,&b[h],m);
Merge(a,h,b);
}
else{
if((m%2)==1)
Copy(b,n,a);
InsertionSort(a,n);
}
}
inline void Merge(int*& a, int& h, int*& buf) // An ultimate Merge function
{
int i = 0; int k = 0; int j = h;
while(1)
{
if(buf[i] <= a[j])
{
a[k] = buf[i];
i++;
if(i == h)
return;
}
else{
a[k] = a[j];
j++;
}
k++;
}
}
void InsertionSort(int* a, int n) // Reduce function call count
{
int j = 1;
while(j < n)
{
int x = a[j]; // Element to be inserted.
int i = j - 1;
while(i >=0)
{
if(a[i] > x)
{
a[i+1] = a[i];
i--;
}
else break;
}
a[i+1]=x; // Insertion
j++;
}
}
D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com
ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134
www.ijera.com 133 | P a g e
III. Profiling Results
In order to measure the actual time improvement achieved by the proposed algorithm, profiling of the
proposed algorithm and existing best algorithm was carried out. Visual Studio 2013 Ultimate software was used
to measure the performance of the proposed and existing best algorithm. Details of existing best algorithm can
be found in literature [2]. Profiling experiments were carried out on random data sets. Results suggest that
proposed algorithm is considerably faster than the existing best algorithm. Following Table 1 and Figure 1
present the profiling statistics.
IV. Conclusion
This research work suggests that proposed algorithm is considerably faster than the existing best
algorithm. It is important to restate that proposed algorithm retains the advantages of existing research work. For
instance, the space requirement is just 50 % of what is required by classical Merge sort. Also, the proposed
algorithm is more adaptive than its classical counterpart. Proposed algorithm delivers better performance on
almost sorted data sets.
Table 1: Comparison on Random Input
Figure 1: Comparative Performance
0
200
400
600
800
1000
1200
1 2 3 4 5 6 7 8 9 10
E
l
a
p
s
e
d
T
i
m
e
N
Series1
Series2
N Existing Best Algorithm
(in ms)
Proposed Algorithm
(in ms)
10000 5.74 2.95
20000 19.19 8.28
30000 22.19 11.92
40000 28.94 18.59
50000 35.91 19.21
60000 36.60 15.95
70000 38.81 22.11
80000 47.66 26.78
90000 759 29.68
100000 1119.80 34.09
D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com
ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134
www.ijera.com 134 | P a g e
References
[1] Donald E. Knuth, The Art of Computer Programming, Vol. 3, Pearson Education, 1998.
[2] http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergef.htm.
[3] S. Baase and A. Gelder, Computer Algorithms:Introduction to Design and Analysis, Addison-Wesley,
2000.
[4] J. L. Bentley, "Programming Pearls: how to sort," Communications of the ACM, Vol. Issue 4, 1986, pp.
287-ff.
[5] T. H. Cormen, C. E. Leiserson, R. L. Rivest and C. Stein, Introduction to Algorithms, Second Edition.
MIT Press and McGraw-Hill, 2001.
[6] P. Biggar, N. Nash, K. Williams, D. Gregg, “An Experimental Study of Sorting and Branch Prediction ,”
Journal of Experimental Algorithmics (JEA), Vol. 12, 2008.
[7] G. Graefe, “Implementing Sorting in Databases,” Computing Surveys (CSUR), Vol. 38, Issue 3. 2004.
[8] T. J. Rolfe, “List Processing: Sort Again, Naturally,” SIGCSE Bulletin ACM , Vol. 37, Issue 2, 2005.

More Related Content

What's hot

9 big o-notation
9 big o-notation9 big o-notation
9 big o-notationirdginfo
 
COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...
COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...
COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...csandit
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Construction Operational Aspects- By Okey Fabian Eze
Construction Operational  Aspects-  By Okey Fabian EzeConstruction Operational  Aspects-  By Okey Fabian Eze
Construction Operational Aspects- By Okey Fabian Ezeokeyeze
 
Searching techniques with progrms
Searching techniques with progrmsSearching techniques with progrms
Searching techniques with progrmsMisssaxena
 
Reducing computational complexity of Mathematical functions using FPGA
Reducing computational complexity of Mathematical functions using FPGAReducing computational complexity of Mathematical functions using FPGA
Reducing computational complexity of Mathematical functions using FPGAnehagaur339
 
Insertion operation in array(ds)
Insertion operation in array(ds)Insertion operation in array(ds)
Insertion operation in array(ds)chauhankapil
 
Clustbigfim frequent itemset mining of
Clustbigfim frequent itemset mining ofClustbigfim frequent itemset mining of
Clustbigfim frequent itemset mining ofijfcstjournal
 
Data structures Lecture no.6
Data structures Lecture no.6Data structures Lecture no.6
Data structures Lecture no.6AzharIqbal710687
 
Algorithms Intro Lecture
Algorithms Intro LectureAlgorithms Intro Lecture
Algorithms Intro LectureIra D
 
A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...
A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...
A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...Xin-She Yang
 

What's hot (19)

9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
Sortsearch
SortsearchSortsearch
Sortsearch
 
Best,worst,average case .17581556 045
Best,worst,average case .17581556 045Best,worst,average case .17581556 045
Best,worst,average case .17581556 045
 
Big o notation
Big o notationBig o notation
Big o notation
 
COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...
COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...
COMPARING THE CUCKOO ALGORITHM WITH OTHER ALGORITHMS FOR ESTIMATING TWO GLSD ...
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Big O Notation
Big O NotationBig O Notation
Big O Notation
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Construction Operational Aspects- By Okey Fabian Eze
Construction Operational  Aspects-  By Okey Fabian EzeConstruction Operational  Aspects-  By Okey Fabian Eze
Construction Operational Aspects- By Okey Fabian Eze
 
Searching techniques with progrms
Searching techniques with progrmsSearching techniques with progrms
Searching techniques with progrms
 
Reducing computational complexity of Mathematical functions using FPGA
Reducing computational complexity of Mathematical functions using FPGAReducing computational complexity of Mathematical functions using FPGA
Reducing computational complexity of Mathematical functions using FPGA
 
Insertion operation in array(ds)
Insertion operation in array(ds)Insertion operation in array(ds)
Insertion operation in array(ds)
 
final
finalfinal
final
 
Clustbigfim frequent itemset mining of
Clustbigfim frequent itemset mining ofClustbigfim frequent itemset mining of
Clustbigfim frequent itemset mining of
 
Data structures Lecture no.6
Data structures Lecture no.6Data structures Lecture no.6
Data structures Lecture no.6
 
Math functions in javascript
Math functions in javascriptMath functions in javascript
Math functions in javascript
 
Algorithms Intro Lecture
Algorithms Intro LectureAlgorithms Intro Lecture
Algorithms Intro Lecture
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...
A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...
A Discrete Firefly Algorithm for the Multi-Objective Hybrid Flowshop Scheduli...
 

Viewers also liked

Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 
The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...Brian Solis
 
Open Source Creativity
Open Source CreativityOpen Source Creativity
Open Source CreativitySara Cannon
 
Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)maditabalnco
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsBarry Feldman
 

Viewers also liked (7)

Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 
The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...
 
Open Source Creativity
Open Source CreativityOpen Source Creativity
Open Source Creativity
 
Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post Formats
 

Similar to V04404131134

IRJET- Efficient Design of Radix Booth Multiplier
IRJET- Efficient Design of Radix Booth MultiplierIRJET- Efficient Design of Radix Booth Multiplier
IRJET- Efficient Design of Radix Booth MultiplierIRJET Journal
 
Modifed Bit-Apriori Algorithm for Frequent Item- Sets in Data Mining
Modifed Bit-Apriori Algorithm for Frequent Item- Sets in Data MiningModifed Bit-Apriori Algorithm for Frequent Item- Sets in Data Mining
Modifed Bit-Apriori Algorithm for Frequent Item- Sets in Data Miningidescitation
 
The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)theijes
 
Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...
Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...
Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...IJERA Editor
 
A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...
A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...
A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...IRJET Journal
 
Testing of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different ProcessorsTesting of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different ProcessorsEditor IJMTER
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Scienceinventy
 
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...BRNSSPublicationHubI
 
Study on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortStudy on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortIRJET Journal
 
A Firefly based improved clustering algorithm
A Firefly based improved clustering algorithmA Firefly based improved clustering algorithm
A Firefly based improved clustering algorithmIRJET Journal
 
ALU Using Area Optimized Vedic Multiplier
ALU Using Area Optimized Vedic MultiplierALU Using Area Optimized Vedic Multiplier
ALU Using Area Optimized Vedic MultiplierIJERA Editor
 
Proposing a scheduling algorithm to balance the time and cost using a genetic...
Proposing a scheduling algorithm to balance the time and cost using a genetic...Proposing a scheduling algorithm to balance the time and cost using a genetic...
Proposing a scheduling algorithm to balance the time and cost using a genetic...Editor IJCATR
 
Job Scheduling on the Grid Environment using Max-Min Firefly Algorithm
Job Scheduling on the Grid Environment using Max-Min  Firefly AlgorithmJob Scheduling on the Grid Environment using Max-Min  Firefly Algorithm
Job Scheduling on the Grid Environment using Max-Min Firefly AlgorithmEditor IJCATR
 
Review on Sorting Algorithms A Comparative Study
Review on Sorting Algorithms A Comparative StudyReview on Sorting Algorithms A Comparative Study
Review on Sorting Algorithms A Comparative StudyCSCJournals
 
Job Shop Layout Design Using Group Technology
Job Shop Layout Design Using Group TechnologyJob Shop Layout Design Using Group Technology
Job Shop Layout Design Using Group TechnologyIJMER
 

Similar to V04404131134 (20)

Sorting_project_2.pdf
Sorting_project_2.pdfSorting_project_2.pdf
Sorting_project_2.pdf
 
IRJET- Efficient Design of Radix Booth Multiplier
IRJET- Efficient Design of Radix Booth MultiplierIRJET- Efficient Design of Radix Booth Multiplier
IRJET- Efficient Design of Radix Booth Multiplier
 
Modifed Bit-Apriori Algorithm for Frequent Item- Sets in Data Mining
Modifed Bit-Apriori Algorithm for Frequent Item- Sets in Data MiningModifed Bit-Apriori Algorithm for Frequent Item- Sets in Data Mining
Modifed Bit-Apriori Algorithm for Frequent Item- Sets in Data Mining
 
Ay4201347349
Ay4201347349Ay4201347349
Ay4201347349
 
The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)The International Journal of Engineering and Science (The IJES)
The International Journal of Engineering and Science (The IJES)
 
Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...
Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...
Aerodynamic Drag Reduction for A Generic Sport Utility Vehicle Using Rear Suc...
 
A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...
A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...
A Novel Design For Generating Dynamic Length Message Digest To Ensure Integri...
 
Testing of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different ProcessorsTesting of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different Processors
 
Job shop
Job shopJob shop
Job shop
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Science
 
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
Hadoop Map-Reduce To Generate Frequent Item Set on Large Datasets Using Impro...
 
Study on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortStudy on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining Sort
 
A Firefly based improved clustering algorithm
A Firefly based improved clustering algorithmA Firefly based improved clustering algorithm
A Firefly based improved clustering algorithm
 
ALU Using Area Optimized Vedic Multiplier
ALU Using Area Optimized Vedic MultiplierALU Using Area Optimized Vedic Multiplier
ALU Using Area Optimized Vedic Multiplier
 
Proposing a scheduling algorithm to balance the time and cost using a genetic...
Proposing a scheduling algorithm to balance the time and cost using a genetic...Proposing a scheduling algorithm to balance the time and cost using a genetic...
Proposing a scheduling algorithm to balance the time and cost using a genetic...
 
Job Scheduling on the Grid Environment using Max-Min Firefly Algorithm
Job Scheduling on the Grid Environment using Max-Min  Firefly AlgorithmJob Scheduling on the Grid Environment using Max-Min  Firefly Algorithm
Job Scheduling on the Grid Environment using Max-Min Firefly Algorithm
 
Review on Sorting Algorithms A Comparative Study
Review on Sorting Algorithms A Comparative StudyReview on Sorting Algorithms A Comparative Study
Review on Sorting Algorithms A Comparative Study
 
Job Shop Layout Design Using Group Technology
Job Shop Layout Design Using Group TechnologyJob Shop Layout Design Using Group Technology
Job Shop Layout Design Using Group Technology
 
Aa4506146150
Aa4506146150Aa4506146150
Aa4506146150
 
Distance Sort
Distance SortDistance Sort
Distance Sort
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

V04404131134

  • 1. D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134 www.ijera.com 131 | P a g e A Fast Merge Sort D.Abhyankar D. Abhyankar, School of Computer Science, D.A. University, Indore M.P. India Abstract Merge sort is one of the most efficient ways to solve sorting problem. Our research suggests that it is still responsive to clever optimizations. A considerably fast variation of Merge sort has been proposed in this paper. Proposed algorithm uses some novel optimizations to improve the speed of the proposed algorithm. Proposed algorithm not only applies some novel optimizations but also retains most of the old optimizations which were effective in reducing space and time. In addition to time and space efficiency, proposed algorithm offers the benefit of elegant design. Profiling has been carried out to verify the effectiveness of proposed algorithm. Profiling results reinforce the fact that proposed algorithm is significantly faster than existing best algorithm. I. Introduction Sorting is one of the most fascinating computational problems that demands a lot of computer time in practical applications. Merge sort is a stable divide and conquer algorithm that solves sorting efficiently. It requires an extra array of size Θ(n) to sort and thus it is not an in-place sorting algorithm. It spends running time Θ(n log n) to sort the input array [1]. Although a lot of research work has been carried out to improve the performance of Merge sort [2], it is still responsive to novel optimizations. Our research offers a better implementation of Merge sort that saves a lot of time and space. Proposed algorithm provides an extremely compact and fast Merge function. Also, it retains the advantages of existing Merge sort variations. This Section is followed by Section 2 that presents the proposed algorithm. Section 3 presents the comparative profiling statistics of the proposed implementation and the existing best Merge sort. In the end, Section 4 concludes and presents the essence of the paper. II. Proposed Implementation The most novel point in proposed algorithm is the amazingly clever sentinel trick accomplished by making the recursively sorted subarrays overlap. This trick eliminates a test in the inner loop by assuring right side of the array contains the last element. That assurance has a cost: lengthening the first of the two recursive sorts so they overlap. It is important to observe that the trick reduces the code size of Merge function. Actual improvement in terms of time has been assessed by profiling in Section 3. It is important to note that proposed implementation retains the existing optimizations on Merge sort. For instance, proposed implementation is a hybrid of Merge sort and Insertion sort. Also, the data move count has been reduced to an extremely low level. Following C++ code formally asserts the implementation. void Merge(int*& a, int& h, int*& buf); void MergeSort(int* a, int n, int* b, int m); void Copy(int* s, int n, int* d); void InsertionSort(int* a, int n); void Sort(int* a, int n) { if(n > 5) { int h = (n+1)/2; int* b = new int[h+1]; MergeSort(b,h+1,a,1); a[h]=b[h]; MergeSort(&a[h],n-h,a,0); Merge(a,h,b); delete[] b; } else{ RESEARCH ARTICLE OPEN ACCESS
  • 2. D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134 www.ijera.com 132 | P a g e InsertionSort(a,n); } } void MergeSort(int* a, int n, int* b, int m) { if(n > 5) { int h = (n/2); MergeSort(b,h+1,a,m+1); a[h]=b[h]; MergeSort(&a[h],n-h,&b[h],m); Merge(a,h,b); } else{ if((m%2)==1) Copy(b,n,a); InsertionSort(a,n); } } inline void Merge(int*& a, int& h, int*& buf) // An ultimate Merge function { int i = 0; int k = 0; int j = h; while(1) { if(buf[i] <= a[j]) { a[k] = buf[i]; i++; if(i == h) return; } else{ a[k] = a[j]; j++; } k++; } } void InsertionSort(int* a, int n) // Reduce function call count { int j = 1; while(j < n) { int x = a[j]; // Element to be inserted. int i = j - 1; while(i >=0) { if(a[i] > x) { a[i+1] = a[i]; i--; } else break; } a[i+1]=x; // Insertion j++; } }
  • 3. D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134 www.ijera.com 133 | P a g e III. Profiling Results In order to measure the actual time improvement achieved by the proposed algorithm, profiling of the proposed algorithm and existing best algorithm was carried out. Visual Studio 2013 Ultimate software was used to measure the performance of the proposed and existing best algorithm. Details of existing best algorithm can be found in literature [2]. Profiling experiments were carried out on random data sets. Results suggest that proposed algorithm is considerably faster than the existing best algorithm. Following Table 1 and Figure 1 present the profiling statistics. IV. Conclusion This research work suggests that proposed algorithm is considerably faster than the existing best algorithm. It is important to restate that proposed algorithm retains the advantages of existing research work. For instance, the space requirement is just 50 % of what is required by classical Merge sort. Also, the proposed algorithm is more adaptive than its classical counterpart. Proposed algorithm delivers better performance on almost sorted data sets. Table 1: Comparison on Random Input Figure 1: Comparative Performance 0 200 400 600 800 1000 1200 1 2 3 4 5 6 7 8 9 10 E l a p s e d T i m e N Series1 Series2 N Existing Best Algorithm (in ms) Proposed Algorithm (in ms) 10000 5.74 2.95 20000 19.19 8.28 30000 22.19 11.92 40000 28.94 18.59 50000 35.91 19.21 60000 36.60 15.95 70000 38.81 22.11 80000 47.66 26.78 90000 759 29.68 100000 1119.80 34.09
  • 4. D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134 www.ijera.com 134 | P a g e References [1] Donald E. Knuth, The Art of Computer Programming, Vol. 3, Pearson Education, 1998. [2] http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergef.htm. [3] S. Baase and A. Gelder, Computer Algorithms:Introduction to Design and Analysis, Addison-Wesley, 2000. [4] J. L. Bentley, "Programming Pearls: how to sort," Communications of the ACM, Vol. Issue 4, 1986, pp. 287-ff. [5] T. H. Cormen, C. E. Leiserson, R. L. Rivest and C. Stein, Introduction to Algorithms, Second Edition. MIT Press and McGraw-Hill, 2001. [6] P. Biggar, N. Nash, K. Williams, D. Gregg, “An Experimental Study of Sorting and Branch Prediction ,” Journal of Experimental Algorithmics (JEA), Vol. 12, 2008. [7] G. Graefe, “Implementing Sorting in Databases,” Computing Surveys (CSUR), Vol. 38, Issue 3. 2004. [8] T. J. Rolfe, “List Processing: Sort Again, Naturally,” SIGCSE Bulletin ACM , Vol. 37, Issue 2, 2005.