SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Department of Mathematics



        Dhaka University
Project Presentation
                  On
Efficiency of sorting algorithms
              Course No: 490
           Session: 2001- 2002
         Class Roll No: Jn-262
  Registration No: 3293/1997-1998

Supervised by: Dr. Amal Krishna Halder
What is sorting algorithms

• The word Sort refer to arrange the records
  according order which may be ascending order
  or descending order.

• The word Algorithm refer to technique or
  process of sorting the records.
What we have done
• Review various sorting algorithms with the help of
  Internet, Library books and our project guide.
• Implement the algorithms by a well known programming
  language C/C++ and test it for various data.
• We contribute something new algorithm structure in the
  sorting algorithm literature.
• We analyzed comparatively and try to find efficiency
  among them.
• We try to make a Conclusion about the efficiency of
  sorting algorithms.
Why we choose sorting algorithms
• There are many reasons why sorting algorithms is of
• Computer can perform million/billion time faster
  interest to computer scientists and mathematicians.
  operations than human. As for example, to find a specific
  data among billion of data computer will take few
• seconds.
  Some algorithms are easy to implement, some algorithms
  take advantage of particular computer architectures, and
• some fast computer search a dataclever. Someits very
  How algorithms are particularly depends on are
  efficient in every stage, some are inefficient for a
  processing power. Processing power depends on
  particular size and type of data. to search a specific data
  processing technique. It is easy
  if it has been sorted earlier. So sorting takes very
• important role for searching data. find out the efficiency
  In our project, our main aim is to
  of various types of sorting algorithm.
Type of sorting
• Internal: if the records that it is sorting are in
  main memory. e.g. Bubble, Quick, Shell etc.

• External: if the records that it is sorting are with
  the help of auxiliary storage. e.g. Radix, Merge,
  Tri-merge(newly proposed)
A sort also can classified as:

• Recursive: if recursive function (the function
  which calls itself in the function) is used .
  e.g. Merge, Quick, Tri-merge(newly proposed)
  etc.

• Non-recursive: if it is not used recursive
  function e.g. Bubble, Insertion, Shell etc.
Overview
• After reviewing various sorting algorithm we
  choose some commonly used sorting algorithm
  that will be listed afterwards.

• For each algorithm we try to describe
  derivation and algorithm with the same
  example for clear understand.
Some Common Sorting Algorithms:
       ⇒Bubble Sort
       ⇒Insertion Sort
       ⇒Selection Sort
       ⇒Replacement Sort
       ⇒Shell Sort
       ⇒Heap Sort
       ⇒Radix Sort
       ⇒Quick Sort
       ⇒Merge Sort
A new approach for sorting algorithm
             literature
• Reviewing various sorting algorithm our knowledge has
  been enriched. We try to work with ternary tree structure
  for sorting algorithm where as generally used binary tree
  structure.
• After facing many problem finally we able to construct a
  successful sorting algorithm which probed to be more
  efficient than binary one.
• Since it uses ternary tree structure and merging technique
  we named it Tri-merge Sort.
• As far as our knowledge goes, this ternary tree structure
  has not yet been used for sorting algorithm.
Problem faced
• At first we faced the problem that if data size can be
  expressed as 3 i (i=1,2…k) then it works properly
  because it splits equally and merge without missing

• But if data size is not an exact multiple of 3 then it
  cannot be split equally and cannot merge from three
  files recursively.

• We fixed the problem by ensuring that data will be
  split recursively until 1 or 2 data remain. This last step
  is treated individually without recursive call and will be
  sort among themselves.
Tri-merge Sort
Formulation:
       Tri-merge is a new proposed technique for sorting
data. It uses the attractive features of the sorting methods
as like of merge sorting. Tri-merge uses ternary tree
structure and recursive function.
       The procedure of Tri-merge sort is completed in
two phases:

Phase-1: Split in to 3 parts recursively.
Phase-2: Merge to 1 part from 3 ordered parts recursively.
Phase-1: Split
• In this stage total data of the given list split into
  3 parts.
• Each part consequently split 3 parts recursively
  until 1 or 2 elements remain.
• When two data remain in a part they are sorted
  among themselves.

• The split procedure will be shown afterward by
  animation.
Phase-2: Merge
• In this phase every 3 split parts become 1 part
  and are sorted among themselves.

• This process continues until all data become
  one part and finally we get completely sorted
  data.

• The merge procedure will be shown afterward
  by animation.
Splitting Recursively
            8   5 2 7 1 3 9 2                   6
    Split to 3 parts Recursively until 1 or 2 data remain



    8       5   2         7   1   3         9   2       6




8       5       2     7       1       3     9       2       6
Merging Recursively

8       5           2        7       1        3       9        2       6


    2   5       8                1   3   7            2     6      9

Compare first element from three files and find smallest one
 Which will be merge to final 3 Sorted files tohere..
   Final Merge From list as like describing 1 Sorted            file

                                         This process will be continue
                                           until all data are merged


            1       2    2       3   5    6       7   8   9
                    Now we get sorted list
Tri-mergeSort( a[L,....,R], L, R )
{      n=R-L+1 (number of element calculated from index position)
       IF (n>2) THEN
       {
                m1 = n/3 (First midpoint)
                m2 = 2*m1 (Second midpoint)
               Tri-mergeSort ( a[L,….,m1], L, m1 )
    Algorithm of Tri-merge sort
               Tri-mergeSort ( a[m1+1,….,m2], m1+1, m2 )
               Tri-mergeSort ( a[m2+1,….,R], m2+1, R )
               Tri-merge ( a[L,….,R], L, m1+1, m2+1, R )
       }                       in
       ELSE IF (n = 2) THEN
       {
          Structural PseudoCode
               IF ( a[L] > a[R] )
               {
                         temp = a[L]
                         a[L] = a[R]
                         a[R] = temp
               }
       }
}
Tri-merge ( a[L,….,R], L, m1, m2, R)
{      part1 = a[L,…,m1-1]; part2 = a[m1,…,m2-1]; part3 = a[m2,…,R]
       TempArray[L,…,R];       n = R-L+1
       IF ( n > 2 )
       {         WHILE( part1, part2 and part3 has elements )
                        Comparing from 3 parts find minimum and set to TempArray.
                 WHILE( part1 and part2 has elements )
                        Comparing from 2 parts find minimum and set to TempArray.
                 WHILE( part2 and part3 has elements )
                        Comparing from 2 parts find minimum and set to TempArray.
                 WHILE( part1 and part3 has elements )
                        Comparing from 2 parts find minimum and set to TempArray.
                 WHILE( part1 has elements )
                        set to TempArray.
                 WHILE( part2 has elements )
                        set to TempArray.
                 WHILE (part3 has elements)
                        set to TempArray.
       }
       RETURN TempArray
}
void TriMergeSort( int a[], int L, int R, long int asscount[],long int comcount[])
{
     int noOfEle=R-L+1;
     int m1,m2,part,t;

     comcount[0]++;
     if(noOfEle>2)
     {
          part=(R-L+1)/3;
          m1 = L+part-1;

     Complete program of
          m2 = L+2*part-1;
          asscount[0]+=3;



       Tri-merge Sort
           TriMergeSort(a,L,m1,asscount,comcount);
           TriMergeSort(a, m1+1,m2,asscount,comcount);
           TriMergeSort(a, m2+1,R,asscount,comcount);

      TriMerge(a,L,m1+1,m2+1,R,asscount,comcount);
      }
      else if(noOfEle==2)
      {
             comcount[0]+=2;
             if(a[L]>a[R])
     {
                   asscount[0]+=3;
                   t=a[L];
                   a[L]=a[R];
Efficiency Analysis
Efficiency of sorting algorithm depends on the
 following criteria:
• How quickly (how much time require) data is sorted.
  CPU time depends on how many operation (assignment
  and compare) count are required for the algorithm
•   How they work for small data
•   How they work for big data
•   How they work for random data
•   How they work for preordered, disordered data and so
    on.
To achieve our goal we have try to do the
                 following task
  Since efficiency (time) depends on number of operations
  so we try to find out the total number of assignment and
  compare operations involved.
• Input data is prepared as random order by C/C++
  programming command.
• To get effect on number of operations for small and big
  data we find out total number of operations for 50, 200,
  400, 600, 800 data.
• We had a limitation to work with huge data (e.g. we have
  used earlier version of C/C++ compiler, Limited
  memory size of the computer.)
To achieve our goal we have try to do the
                 following task
  For comparative analysis we arrange total number of
  operation count in different table with different number
  of data (e.g. 50, 200, 400, 600, 800) including 100%, 80%,
  10%, random, totally disordered.
• To compare the result clearly we show them graphically
  so that one can get the picture at a glance.
• Analyzing the obtained data we try to find out an
  approximation function of operation count f(n), where n
  is the number of data. To get the function we use the
  technique of interpolation. This function is also serves
  an indication about the efficiency of the algorithm.
The Table of
Operation Count
For 50 Data total operation count with different ordered
Sort Name     100%     80%        10% Order Random Completely
              Order    Ordered                       Disorder
Bubble            3775       4153       5305    5335        7405
Insertion          245        749       2285    2325        5085
Selection         3975       4010       4071    4095        4445
Replacement       3775       4108       5086    5026        6154
Heap              2899       2773       2532    2479        2145
Shell              582        838       1186    1270        1622
Radix              706        706        706     706          706
Quick             4172       1615       1355    1204        4147
Merge             3163       3195       3205    3209        3145
TriMerge(New)     2078       2441       2560    2596        2443




   For 800 Data total operation count with different ordered
Sort Name     100%     80%       10% Order Random Completely
              Order    Ordered                      Disorder
Bubble         9226764   1063453    1259566 1447693     2756473
Insertion       509393    141399     402883  653719      619815
Selection       964759    964760     965474  966869      967801
Replacement     823641   1005562    1049428 1065151     1076530
Heap             73640     70835      68372   65851       64712
Shell            18494     41607     100366  148267      152850
Radix             9706      9706       9706    9706        9706
Quick            82110     54429      46866   37285       83002
Merge            80945     82205      83143   83455       84013
TriMerge(New)    72984     75943      79611   79993       79732
Approximate Operation count function f(n) with
                 respect to number of data n
Name of sorting algorithm         f(n)=Number of operation count
                                       (n = Number of data)
Bubble                                           2*n2

Insertion                                         n2

Selection                                       1.5*n2

Replacement                                     1.7*n2

Heap                                        28(n * Log n)

Shell                                       39(n * Log n)

Radix                                        5(n * Log n)

Quick                                       14(n * Log n)

Merge                                       36(n * Log n)

Tri-merge(New)                              32(n * Log n)
Graphical Representation
      According
Operation Count Function
Summary
Bubble Sort is a very slow way of sorting; its
  main advantage is the simplicity of the
  algorithm.
Insertion Sort is much efficient for ordered,
  preordered and small data. For disorder and
  large data its efficiency goes inversely.

Selection sort works nearly same for all types
   (ordered, preordered, random, disordered) of
   data. It is more efficient for small data than
   large one.
Replacement sort is also a slow procedure as
  bubble sort, it is not so efficient one.
Heap sort works well for disordered and data
  than preordered data. It also works well for
  big data.
Shell sort is more efficient for ordered data; it
  also works very well for small data but very
  slow for disordered data.
Radix sort is much more efficient than any
  other sorting algorithm. It works well for all
  types of ordered, disordered and random
  data; basically it gives exactly the same
  number of operations for all of those types.
  In our observation
Quick sort is more efficient for random data. It
  is bad for fully ordered and fully disordered
  data.
Merge sort gives nearly same number of
  operation for all types of data. It is more
  efficient for big data.
Tri-merge sort gives much better result than the
  merge sort, i.e. it is more efficient than
  merge.
Ranking of sorting algorithm:
 
    It is very difficult to make ranking order of sorting algorithm according to
    their efficiency. Some works very well for small data and some well for big
    data. Similarly some works well for preordered data some works well for
    random data. After all we try to find out a general rank order for average
    situation.
   Radix sort
   Quick sort
   Heap sort
   Tri-merge (newly proposed)
   Merge sort
   Shell sort
   Insertion sort
   Selection sort
   Replacement sort
   Bubble sort.
Sort
                       Bubble     Inser    Selec    Replace                                                    Tri-
                                                                 Heap      Shell   Radix    Quick    Merge
                                   tion    tion      Ment                                                     merge
      Type

                                                     Most        Most     Most                       Fairly   Fairly
     Algorithm        Most Easy   Easy     Easy
                                                     Easy        Hard     Hard
                                                                                   Easy     Hard
                                                                                                     Hard     Hard


                                  Fairly                                  Fairly   Very     Very
 For Random Data      Very Bad
                                   Bad
                                           Bad     Fairly Bad    Good
                                                                          Good     Good     good
                                                                                                     Good     Good



                      Very Bad    Fairly   Very                           Very     Very     Very     Fairly
 For Ordered Data                 Good     Bad
                                                      Bad         Bad
                                                                          Good     Good     bad      Good
                                                                                                              Good



                                  Very                                    Fairly   Very     Very
For Disordered Data   Very Bad
                                  Bad
                                           Bad        Bad        Good
                                                                          Good     Good     bad
                                                                                                     Good     Good


                                                                                   Very     Very     Fairly   Fairly
  For Small Data      Very Bad    Good     Bad     Very Bad      Good     Good
                                                                                   Good     Good     Good     Good

                                                                          Fairly   Very
   For Big Data       Very Bad    Bad      Bad     Vary Bad      Good
                                                                           Bad     Good
                                                                                            Good     Good     Good

                                           1.5*                   28*      39*      5*      14*      36*      32*
                              2        2    n2               2   nLog10 n nLog10 n nLog10 n nLog10 n nLog10 n nLog10 n
Obtained Complexity    2* n        n                1.7* n




     Conclusion Table at a glance
End

Weitere ähnliche Inhalte

Was ist angesagt?

Ms publisher-2003
Ms publisher-2003Ms publisher-2003
Ms publisher-2003slavinskiy
 
8. Multi List (Struktur Data)
8. Multi List (Struktur Data)8. Multi List (Struktur Data)
8. Multi List (Struktur Data)Kelinci Coklat
 
Формування інформаційної компетентності на уроках математики
Формування інформаційної компетентності на уроках математикиФормування інформаційної компетентності на уроках математики
Формування інформаційної компетентності на уроках математикиnatalinka2016
 
виникнення інформаційних технологій
виникнення інформаційних технологійвиникнення інформаційних технологій
виникнення інформаційних технологійIrina Semenova
 
многогранники обєми та площі поверхонь многогранників
многогранники обєми та площі поверхонь многогранниківмногогранники обєми та площі поверхонь многогранників
многогранники обєми та площі поверхонь многогранниківЮра Марчук
 
паралелепіпед
паралелепіпедпаралелепіпед
паралелепіпедyahnoluida
 
Pojam logaritma i logaritamska funkcija
Pojam logaritma i logaritamska funkcijaPojam logaritma i logaritamska funkcija
Pojam logaritma i logaritamska funkcijaMarkoM6
 
Чотирикутники
ЧотирикутникиЧотирикутники
ЧотирикутникиFormula.co.ua
 
OOP - Collections
OOP - CollectionsOOP - Collections
OOP - CollectionsKuliahKita
 
застосування похідної в різних сферах життя людини
застосування похідної в різних сферах життя людинизастосування похідної в різних сферах життя людини
застосування похідної в різних сферах життя людиниden2002
 
C++ Array Gerobak Fried Chicken
C++ Array Gerobak Fried ChickenC++ Array Gerobak Fried Chicken
C++ Array Gerobak Fried ChickenDoni Andriansyah
 
Laporan PBO Pratikum 3
Laporan PBO Pratikum 3Laporan PBO Pratikum 3
Laporan PBO Pratikum 3rahmi wahyuni
 
18361 збірник контрольних робіт 6 клас
18361 збірник контрольних робіт 6 клас18361 збірник контрольних робіт 6 клас
18361 збірник контрольних робіт 6 класАлександр Гергардт
 
Algoritma dan Struktur Data - Sequential Search
Algoritma dan Struktur Data - Sequential SearchAlgoritma dan Struktur Data - Sequential Search
Algoritma dan Struktur Data - Sequential SearchKuliahKita
 
6 Algoritma Pengurutan Data
6 Algoritma Pengurutan Data6 Algoritma Pengurutan Data
6 Algoritma Pengurutan DataSimon Patabang
 

Was ist angesagt? (20)

Aries
AriesAries
Aries
 
Ms publisher-2003
Ms publisher-2003Ms publisher-2003
Ms publisher-2003
 
8. Multi List (Struktur Data)
8. Multi List (Struktur Data)8. Multi List (Struktur Data)
8. Multi List (Struktur Data)
 
Формування інформаційної компетентності на уроках математики
Формування інформаційної компетентності на уроках математикиФормування інформаційної компетентності на уроках математики
Формування інформаційної компетентності на уроках математики
 
виникнення інформаційних технологій
виникнення інформаційних технологійвиникнення інформаційних технологій
виникнення інформаційних технологій
 
многогранники обєми та площі поверхонь многогранників
многогранники обєми та площі поверхонь многогранниківмногогранники обєми та площі поверхонь многогранників
многогранники обєми та площі поверхонь многогранників
 
паралелепіпед
паралелепіпедпаралелепіпед
паралелепіпед
 
Pojam logaritma i logaritamska funkcija
Pojam logaritma i logaritamska funkcijaPojam logaritma i logaritamska funkcija
Pojam logaritma i logaritamska funkcija
 
Чотирикутники
ЧотирикутникиЧотирикутники
Чотирикутники
 
OOP - Collections
OOP - CollectionsOOP - Collections
OOP - Collections
 
застосування похідної в різних сферах життя людини
застосування похідної в різних сферах життя людинизастосування похідної в різних сферах життя людини
застосування похідної в різних сферах життя людини
 
3 6 excel
3 6 excel3 6 excel
3 6 excel
 
C++ Array Gerobak Fried Chicken
C++ Array Gerobak Fried ChickenC++ Array Gerobak Fried Chicken
C++ Array Gerobak Fried Chicken
 
Laporan PBO Pratikum 3
Laporan PBO Pratikum 3Laporan PBO Pratikum 3
Laporan PBO Pratikum 3
 
18361 збірник контрольних робіт 6 клас
18361 збірник контрольних робіт 6 клас18361 збірник контрольних робіт 6 клас
18361 збірник контрольних робіт 6 клас
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
Algoritma dan Struktur Data - Sequential Search
Algoritma dan Struktur Data - Sequential SearchAlgoritma dan Struktur Data - Sequential Search
Algoritma dan Struktur Data - Sequential Search
 
6 Algoritma Pengurutan Data
6 Algoritma Pengurutan Data6 Algoritma Pengurutan Data
6 Algoritma Pengurutan Data
 
sql Modul
sql Modulsql Modul
sql Modul
 
Sistem File
Sistem FileSistem File
Sistem File
 

Andere mochten auch

National Air And Space Museum Washington DC
National Air And Space Museum Washington DCNational Air And Space Museum Washington DC
National Air And Space Museum Washington DCShivakumar Patil
 
History of Google Local from 2004-2011
History of Google Local from 2004-2011 History of Google Local from 2004-2011
History of Google Local from 2004-2011 Mike Blumenthal
 
One Long Argument
One Long ArgumentOne Long Argument
One Long ArgumentJohn Lynch
 
Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"John Lynch
 
Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.Saba SEO
 
The Chemical Revolution
The Chemical RevolutionThe Chemical Revolution
The Chemical RevolutionJohn Lynch
 
Introduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_bIntroduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_bShahi Raz Akhtar
 
History of Creationism, Parts II & III
History of Creationism, Parts II & IIIHistory of Creationism, Parts II & III
History of Creationism, Parts II & IIIJohn Lynch
 
Google at a glance 1998 - 2008
Google at a glance 1998 - 2008Google at a glance 1998 - 2008
Google at a glance 1998 - 2008Andreas Jaffke
 
Why Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & ScienceWhy Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & ScienceJohn Lynch
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithmspppepito86
 
A history of science (volume 1)
A history of science (volume 1) A history of science (volume 1)
A history of science (volume 1) Dipoceanov Esrever
 
Was There A Darwinian Revolution
Was There A Darwinian RevolutionWas There A Darwinian Revolution
Was There A Darwinian RevolutionJohn Lynch
 

Andere mochten auch (20)

National Air And Space Museum Washington DC
National Air And Space Museum Washington DCNational Air And Space Museum Washington DC
National Air And Space Museum Washington DC
 
History of Google Local from 2004-2011
History of Google Local from 2004-2011 History of Google Local from 2004-2011
History of Google Local from 2004-2011
 
One Long Argument
One Long ArgumentOne Long Argument
One Long Argument
 
Ds 4
Ds 4Ds 4
Ds 4
 
Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"
 
Chap04alg
Chap04algChap04alg
Chap04alg
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
simple-sorting algorithms
simple-sorting algorithmssimple-sorting algorithms
simple-sorting algorithms
 
Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.
 
The Chemical Revolution
The Chemical RevolutionThe Chemical Revolution
The Chemical Revolution
 
Introduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_bIntroduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_b
 
Sorting pnk
Sorting pnkSorting pnk
Sorting pnk
 
sPen Data Management
sPen Data ManagementsPen Data Management
sPen Data Management
 
History of Creationism, Parts II & III
History of Creationism, Parts II & IIIHistory of Creationism, Parts II & III
History of Creationism, Parts II & III
 
Google at a glance 1998 - 2008
Google at a glance 1998 - 2008Google at a glance 1998 - 2008
Google at a glance 1998 - 2008
 
Why Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & ScienceWhy Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & Science
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
A history of science (volume 1)
A history of science (volume 1) A history of science (volume 1)
A history of science (volume 1)
 
Was There A Darwinian Revolution
Was There A Darwinian RevolutionWas There A Darwinian Revolution
Was There A Darwinian Revolution
 
Google
GoogleGoogle
Google
 

Ähnlich wie Tri Merge Sorting Algorithm

Class13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfClass13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfAkashSingh625550
 
Introduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptxIntroduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptxPJS KUMAR
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxShivamKrPathak
 
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
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)jehan1987
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAdelina Ahadova
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureRai University
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0BG Java EE Course
 
algorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptxalgorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptxkassahungebrie
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.pptArumugam90
 
Lecture 2 data structures & algorithms - sorting techniques
Lecture 2  data structures & algorithms - sorting techniquesLecture 2  data structures & algorithms - sorting techniques
Lecture 2 data structures & algorithms - sorting techniquesDharmendra Prasad
 
Data Structures Notes
Data Structures NotesData Structures Notes
Data Structures NotesRobinRohit2
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureRai University
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESAniruddha Paul
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureRai University
 

Ähnlich wie Tri Merge Sorting Algorithm (20)

Class13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfClass13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdf
 
Ds
DsDs
Ds
 
Introduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptxIntroduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptx
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
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
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
Big O Notation
Big O NotationBig O Notation
Big O Notation
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
algorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptxalgorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptx
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.ppt
 
Lecture 2 data structures & algorithms - sorting techniques
Lecture 2  data structures & algorithms - sorting techniquesLecture 2  data structures & algorithms - sorting techniques
Lecture 2 data structures & algorithms - sorting techniques
 
Data Structures Notes
Data Structures NotesData Structures Notes
Data Structures Notes
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
my docoment
my docomentmy docoment
my docoment
 

Mehr von Ashim Sikder

5. Cloud-BuyingHouse ERP Overview
5. Cloud-BuyingHouse ERP Overview5. Cloud-BuyingHouse ERP Overview
5. Cloud-BuyingHouse ERP OverviewAshim Sikder
 
Cloud-Hospital Overview
Cloud-Hospital OverviewCloud-Hospital Overview
Cloud-Hospital OverviewAshim Sikder
 
Cloud-HRMS Overview
Cloud-HRMS OverviewCloud-HRMS Overview
Cloud-HRMS OverviewAshim Sikder
 
Cloud-Payroll Overview
Cloud-Payroll OverviewCloud-Payroll Overview
Cloud-Payroll OverviewAshim Sikder
 
Cloud Solution Ltd. : Company Profile
Cloud Solution Ltd. : Company ProfileCloud Solution Ltd. : Company Profile
Cloud Solution Ltd. : Company ProfileAshim Sikder
 
Mobile based Accounting and Business Management System
Mobile based Accounting and Business Management SystemMobile based Accounting and Business Management System
Mobile based Accounting and Business Management SystemAshim Sikder
 
Accounting Learning Tutorial
Accounting Learning TutorialAccounting Learning Tutorial
Accounting Learning TutorialAshim Sikder
 
Online cloud academy management software features
Online cloud academy management software featuresOnline cloud academy management software features
Online cloud academy management software featuresAshim Sikder
 
Online Cloud payroll management software Tutorial
Online Cloud payroll management software TutorialOnline Cloud payroll management software Tutorial
Online Cloud payroll management software TutorialAshim Sikder
 
Online Cloud based Accounting Software for Personal or Small Business
Online Cloud based Accounting Software for Personal or Small BusinessOnline Cloud based Accounting Software for Personal or Small Business
Online Cloud based Accounting Software for Personal or Small BusinessAshim Sikder
 

Mehr von Ashim Sikder (10)

5. Cloud-BuyingHouse ERP Overview
5. Cloud-BuyingHouse ERP Overview5. Cloud-BuyingHouse ERP Overview
5. Cloud-BuyingHouse ERP Overview
 
Cloud-Hospital Overview
Cloud-Hospital OverviewCloud-Hospital Overview
Cloud-Hospital Overview
 
Cloud-HRMS Overview
Cloud-HRMS OverviewCloud-HRMS Overview
Cloud-HRMS Overview
 
Cloud-Payroll Overview
Cloud-Payroll OverviewCloud-Payroll Overview
Cloud-Payroll Overview
 
Cloud Solution Ltd. : Company Profile
Cloud Solution Ltd. : Company ProfileCloud Solution Ltd. : Company Profile
Cloud Solution Ltd. : Company Profile
 
Mobile based Accounting and Business Management System
Mobile based Accounting and Business Management SystemMobile based Accounting and Business Management System
Mobile based Accounting and Business Management System
 
Accounting Learning Tutorial
Accounting Learning TutorialAccounting Learning Tutorial
Accounting Learning Tutorial
 
Online cloud academy management software features
Online cloud academy management software featuresOnline cloud academy management software features
Online cloud academy management software features
 
Online Cloud payroll management software Tutorial
Online Cloud payroll management software TutorialOnline Cloud payroll management software Tutorial
Online Cloud payroll management software Tutorial
 
Online Cloud based Accounting Software for Personal or Small Business
Online Cloud based Accounting Software for Personal or Small BusinessOnline Cloud based Accounting Software for Personal or Small Business
Online Cloud based Accounting Software for Personal or Small Business
 

Kürzlich hochgeladen

Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptxRajatChauhan518211
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticssakshisoni2385
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyDrAnita Sharma
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfrohankumarsinghrore1
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)Areesha Ahmad
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 

Kürzlich hochgeladen (20)

Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptx
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomology
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 

Tri Merge Sorting Algorithm

  • 1. Department of Mathematics Dhaka University
  • 2. Project Presentation On Efficiency of sorting algorithms Course No: 490 Session: 2001- 2002 Class Roll No: Jn-262 Registration No: 3293/1997-1998 Supervised by: Dr. Amal Krishna Halder
  • 3. What is sorting algorithms • The word Sort refer to arrange the records according order which may be ascending order or descending order. • The word Algorithm refer to technique or process of sorting the records.
  • 4. What we have done • Review various sorting algorithms with the help of Internet, Library books and our project guide. • Implement the algorithms by a well known programming language C/C++ and test it for various data. • We contribute something new algorithm structure in the sorting algorithm literature. • We analyzed comparatively and try to find efficiency among them. • We try to make a Conclusion about the efficiency of sorting algorithms.
  • 5. Why we choose sorting algorithms • There are many reasons why sorting algorithms is of • Computer can perform million/billion time faster interest to computer scientists and mathematicians. operations than human. As for example, to find a specific data among billion of data computer will take few • seconds. Some algorithms are easy to implement, some algorithms take advantage of particular computer architectures, and • some fast computer search a dataclever. Someits very How algorithms are particularly depends on are efficient in every stage, some are inefficient for a processing power. Processing power depends on particular size and type of data. to search a specific data processing technique. It is easy if it has been sorted earlier. So sorting takes very • important role for searching data. find out the efficiency In our project, our main aim is to of various types of sorting algorithm.
  • 6. Type of sorting • Internal: if the records that it is sorting are in main memory. e.g. Bubble, Quick, Shell etc. • External: if the records that it is sorting are with the help of auxiliary storage. e.g. Radix, Merge, Tri-merge(newly proposed)
  • 7. A sort also can classified as: • Recursive: if recursive function (the function which calls itself in the function) is used . e.g. Merge, Quick, Tri-merge(newly proposed) etc. • Non-recursive: if it is not used recursive function e.g. Bubble, Insertion, Shell etc.
  • 8. Overview • After reviewing various sorting algorithm we choose some commonly used sorting algorithm that will be listed afterwards. • For each algorithm we try to describe derivation and algorithm with the same example for clear understand.
  • 9. Some Common Sorting Algorithms: ⇒Bubble Sort ⇒Insertion Sort ⇒Selection Sort ⇒Replacement Sort ⇒Shell Sort ⇒Heap Sort ⇒Radix Sort ⇒Quick Sort ⇒Merge Sort
  • 10. A new approach for sorting algorithm literature • Reviewing various sorting algorithm our knowledge has been enriched. We try to work with ternary tree structure for sorting algorithm where as generally used binary tree structure. • After facing many problem finally we able to construct a successful sorting algorithm which probed to be more efficient than binary one. • Since it uses ternary tree structure and merging technique we named it Tri-merge Sort. • As far as our knowledge goes, this ternary tree structure has not yet been used for sorting algorithm.
  • 11. Problem faced • At first we faced the problem that if data size can be expressed as 3 i (i=1,2…k) then it works properly because it splits equally and merge without missing • But if data size is not an exact multiple of 3 then it cannot be split equally and cannot merge from three files recursively. • We fixed the problem by ensuring that data will be split recursively until 1 or 2 data remain. This last step is treated individually without recursive call and will be sort among themselves.
  • 12. Tri-merge Sort Formulation: Tri-merge is a new proposed technique for sorting data. It uses the attractive features of the sorting methods as like of merge sorting. Tri-merge uses ternary tree structure and recursive function. The procedure of Tri-merge sort is completed in two phases: Phase-1: Split in to 3 parts recursively. Phase-2: Merge to 1 part from 3 ordered parts recursively.
  • 13. Phase-1: Split • In this stage total data of the given list split into 3 parts. • Each part consequently split 3 parts recursively until 1 or 2 elements remain. • When two data remain in a part they are sorted among themselves. • The split procedure will be shown afterward by animation.
  • 14. Phase-2: Merge • In this phase every 3 split parts become 1 part and are sorted among themselves. • This process continues until all data become one part and finally we get completely sorted data. • The merge procedure will be shown afterward by animation.
  • 15. Splitting Recursively 8 5 2 7 1 3 9 2 6 Split to 3 parts Recursively until 1 or 2 data remain 8 5 2 7 1 3 9 2 6 8 5 2 7 1 3 9 2 6
  • 16. Merging Recursively 8 5 2 7 1 3 9 2 6 2 5 8 1 3 7 2 6 9 Compare first element from three files and find smallest one Which will be merge to final 3 Sorted files tohere.. Final Merge From list as like describing 1 Sorted file This process will be continue until all data are merged 1 2 2 3 5 6 7 8 9 Now we get sorted list
  • 17. Tri-mergeSort( a[L,....,R], L, R ) { n=R-L+1 (number of element calculated from index position) IF (n>2) THEN { m1 = n/3 (First midpoint) m2 = 2*m1 (Second midpoint) Tri-mergeSort ( a[L,….,m1], L, m1 ) Algorithm of Tri-merge sort Tri-mergeSort ( a[m1+1,….,m2], m1+1, m2 ) Tri-mergeSort ( a[m2+1,….,R], m2+1, R ) Tri-merge ( a[L,….,R], L, m1+1, m2+1, R ) } in ELSE IF (n = 2) THEN { Structural PseudoCode IF ( a[L] > a[R] ) { temp = a[L] a[L] = a[R] a[R] = temp } } }
  • 18. Tri-merge ( a[L,….,R], L, m1, m2, R) { part1 = a[L,…,m1-1]; part2 = a[m1,…,m2-1]; part3 = a[m2,…,R] TempArray[L,…,R]; n = R-L+1 IF ( n > 2 ) { WHILE( part1, part2 and part3 has elements ) Comparing from 3 parts find minimum and set to TempArray. WHILE( part1 and part2 has elements ) Comparing from 2 parts find minimum and set to TempArray. WHILE( part2 and part3 has elements ) Comparing from 2 parts find minimum and set to TempArray. WHILE( part1 and part3 has elements ) Comparing from 2 parts find minimum and set to TempArray. WHILE( part1 has elements ) set to TempArray. WHILE( part2 has elements ) set to TempArray. WHILE (part3 has elements) set to TempArray. } RETURN TempArray }
  • 19. void TriMergeSort( int a[], int L, int R, long int asscount[],long int comcount[]) { int noOfEle=R-L+1; int m1,m2,part,t; comcount[0]++; if(noOfEle>2) { part=(R-L+1)/3; m1 = L+part-1; Complete program of m2 = L+2*part-1; asscount[0]+=3; Tri-merge Sort TriMergeSort(a,L,m1,asscount,comcount); TriMergeSort(a, m1+1,m2,asscount,comcount); TriMergeSort(a, m2+1,R,asscount,comcount); TriMerge(a,L,m1+1,m2+1,R,asscount,comcount); } else if(noOfEle==2) { comcount[0]+=2; if(a[L]>a[R]) { asscount[0]+=3; t=a[L]; a[L]=a[R];
  • 20.
  • 21. Efficiency Analysis Efficiency of sorting algorithm depends on the following criteria: • How quickly (how much time require) data is sorted. CPU time depends on how many operation (assignment and compare) count are required for the algorithm • How they work for small data • How they work for big data • How they work for random data • How they work for preordered, disordered data and so on.
  • 22. To achieve our goal we have try to do the following task Since efficiency (time) depends on number of operations so we try to find out the total number of assignment and compare operations involved. • Input data is prepared as random order by C/C++ programming command. • To get effect on number of operations for small and big data we find out total number of operations for 50, 200, 400, 600, 800 data. • We had a limitation to work with huge data (e.g. we have used earlier version of C/C++ compiler, Limited memory size of the computer.)
  • 23. To achieve our goal we have try to do the following task For comparative analysis we arrange total number of operation count in different table with different number of data (e.g. 50, 200, 400, 600, 800) including 100%, 80%, 10%, random, totally disordered. • To compare the result clearly we show them graphically so that one can get the picture at a glance. • Analyzing the obtained data we try to find out an approximation function of operation count f(n), where n is the number of data. To get the function we use the technique of interpolation. This function is also serves an indication about the efficiency of the algorithm.
  • 25. For 50 Data total operation count with different ordered Sort Name 100% 80% 10% Order Random Completely Order Ordered Disorder Bubble 3775 4153 5305 5335 7405 Insertion 245 749 2285 2325 5085 Selection 3975 4010 4071 4095 4445 Replacement 3775 4108 5086 5026 6154 Heap 2899 2773 2532 2479 2145 Shell 582 838 1186 1270 1622 Radix 706 706 706 706 706 Quick 4172 1615 1355 1204 4147 Merge 3163 3195 3205 3209 3145 TriMerge(New) 2078 2441 2560 2596 2443 For 800 Data total operation count with different ordered Sort Name 100% 80% 10% Order Random Completely Order Ordered Disorder Bubble 9226764 1063453 1259566 1447693 2756473 Insertion 509393 141399 402883 653719 619815 Selection 964759 964760 965474 966869 967801 Replacement 823641 1005562 1049428 1065151 1076530 Heap 73640 70835 68372 65851 64712 Shell 18494 41607 100366 148267 152850 Radix 9706 9706 9706 9706 9706 Quick 82110 54429 46866 37285 83002 Merge 80945 82205 83143 83455 84013 TriMerge(New) 72984 75943 79611 79993 79732
  • 26.
  • 27. Approximate Operation count function f(n) with respect to number of data n Name of sorting algorithm f(n)=Number of operation count (n = Number of data) Bubble 2*n2 Insertion n2 Selection 1.5*n2 Replacement 1.7*n2 Heap 28(n * Log n) Shell 39(n * Log n) Radix 5(n * Log n) Quick 14(n * Log n) Merge 36(n * Log n) Tri-merge(New) 32(n * Log n)
  • 28. Graphical Representation According Operation Count Function
  • 29.
  • 31. Bubble Sort is a very slow way of sorting; its main advantage is the simplicity of the algorithm. Insertion Sort is much efficient for ordered, preordered and small data. For disorder and large data its efficiency goes inversely. Selection sort works nearly same for all types (ordered, preordered, random, disordered) of data. It is more efficient for small data than large one. Replacement sort is also a slow procedure as bubble sort, it is not so efficient one. Heap sort works well for disordered and data than preordered data. It also works well for big data.
  • 32. Shell sort is more efficient for ordered data; it also works very well for small data but very slow for disordered data. Radix sort is much more efficient than any other sorting algorithm. It works well for all types of ordered, disordered and random data; basically it gives exactly the same number of operations for all of those types. In our observation Quick sort is more efficient for random data. It is bad for fully ordered and fully disordered data. Merge sort gives nearly same number of operation for all types of data. It is more efficient for big data. Tri-merge sort gives much better result than the merge sort, i.e. it is more efficient than merge.
  • 33. Ranking of sorting algorithm:   It is very difficult to make ranking order of sorting algorithm according to their efficiency. Some works very well for small data and some well for big data. Similarly some works well for preordered data some works well for random data. After all we try to find out a general rank order for average situation.  Radix sort  Quick sort  Heap sort  Tri-merge (newly proposed)  Merge sort  Shell sort  Insertion sort  Selection sort  Replacement sort  Bubble sort.
  • 34. Sort Bubble Inser Selec Replace Tri- Heap Shell Radix Quick Merge tion tion Ment merge Type Most Most Most Fairly Fairly Algorithm Most Easy Easy Easy Easy Hard Hard Easy Hard Hard Hard Fairly Fairly Very Very For Random Data Very Bad Bad Bad Fairly Bad Good Good Good good Good Good Very Bad Fairly Very Very Very Very Fairly For Ordered Data Good Bad Bad Bad Good Good bad Good Good Very Fairly Very Very For Disordered Data Very Bad Bad Bad Bad Good Good Good bad Good Good Very Very Fairly Fairly For Small Data Very Bad Good Bad Very Bad Good Good Good Good Good Good Fairly Very For Big Data Very Bad Bad Bad Vary Bad Good Bad Good Good Good Good 1.5* 28* 39* 5* 14* 36* 32* 2 2 n2 2 nLog10 n nLog10 n nLog10 n nLog10 n nLog10 n nLog10 n Obtained Complexity 2* n n 1.7* n Conclusion Table at a glance
  • 35. End