Professional Documents
Culture Documents
The Rum Time Analysis of Binary and Ternary Merge Sort
The Rum Time Analysis of Binary and Ternary Merge Sort
0.03
0.03
time
0.02
runtime binary
runtime
tarnary
0.02
0.01
0.01
0
0
20000
40000
60000
80000
100000
120000
element size
Fig. Binary Merge Sort and Ternary Merge Sort data size vs time graph
Description:
RunTime:
1. Initiallythebothalgorithmworkedforsametimeforlimitedamountofdata.
2. ButwhenthedataincreasestheTernaryMergeSorttookplaceovertheBinary
Mergesortforquicksorting.
3. AtlargescaleofdatatheBinaryMergesorttakemuchmoretimethanthe
TernaryMargesort.
Timecomplexityanalysis:
1. ThetimecomplexityofBinaryMergesortis=log2(n);n=numberofelement.
2. ThetimecomplexityofTernaryMergesortis=log3(n);n=numberofelement.
Theory:
Ifwecouldsplitthearrayinto
=2.7183partsthentheruntimewouldbe
ratherlogx(n)thenthealgorithmwouldbethequickestevenforthelargest
worstcaseinstance.Butthisisimpossibletosplit.
Summary:
So,wecantellthatBinaryMergesortisisgoodforlowamountofdatabutforlarge
scaleofdataTernaryMergesortisgood.
Thankyou!