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

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

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.