1 / 11

Analysis of Quick Sort and Merge Sort

Analysis of Quick Sort and Merge Sort. Aditya Bhutra. Implementation. Code written in JAVA (JDK 6) Standard Quick Sort and Merge Sort methods Implemented Array Sizes vary from 10 6 to 5 x 10 7 . Array Elements contain double precision floating point random numbers between 0 and 1 .

neva
Télécharger la présentation

Analysis of Quick Sort and Merge Sort

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Analysis of Quick Sort and Merge Sort Aditya Bhutra

  2. Implementation • Code written in JAVA (JDK 6) • Standard Quick Sort and Merge Sort methods Implemented • Array Sizes vary from 106 to 5x107 . • Array Elements contain double precision floating point random numbers between 0 and 1 . • Computing 1000 iterations for each Array Size . • Time measured for each sort is measured in nanoseconds using System.nanoTime() method. • Normalised time is calculated as Time/nlog(n) . • Normalised number of Comparisons is also calculated as Comparisons/nlog(n)

  3. Code Snippet

  4. Quick Sort Array Sizes Performance increases with Array Size.

  5. Merge Sort (constant Memory) Array Sizes Performance worsens with increasing Array Size .

  6. Merge Sort(constant Array Size) Array Size = 106 AllottedMemory Performance increases with increasing Memory space.

  7. Observations • Normalised Number of Comparisons remains almost constantwith Array Size for both Sorting methods . • Merge Sort – Slightly Incresing • Quick Sort – Slightly Decreasing • Abnormal decrease in the value of Merge Comparisons for Array Size of 5*107 . • Merge comparisons exceed twice the number of Quick Comparisons. • (except the 5*107 case.)

  8. Conclusions • Quick Sort performs better with increasing Array Size. • Merge Sort performs worse with increasing Array Size. • Quick Sort performance remains independent of Allocated Memory. • Merge Sort performance is enhanced by increasing Allocated Memory. • For Smaller Array Sizes ( < 2 x 106 ) , Merge Sort performs better than Quick Sort if sufficient memory is allocated. • Unlike Merge Sort , in Quick Sort , the frequency curve sharpens with increasing Array Size . This signifies that Quick Sort becomes more reliable for very large Array Sizes.

More Related