Heap Sort - Performance

This section provides a tutorial on how to measure the performance of the Heap Sort algorithm. My first Java implementation of Heap Sort is performing somewhere between O(N*Log2(N) and O(N*N) order levels.

Now let's see how my Java implementation of the Heap Sort algorithm performs. I tried this implementation with my SortTest.java under JDK 1.3.1. Here are the results:

Array size: 10000
Average sorting time: 29 milliseconds
Number of tests: 1000
Performance: 2.9 O(N) nanoseconds
Performance: 0.21824674685638637 O(N*Log2(N)) nanoseconds
Performance: 2.9E-4 O(N*N) nanoseconds

Array size: 20000
Average sorting time: 76 milliseconds
Number of tests: 1000
Performance: 3.8 O(N) nanoseconds
Performance: 0.2659628006957283 O(N*Log2(N)) nanoseconds
Performance: 1.9E-4 O(N*N) nanoseconds

Array size: 30000
Average sorting time: 134 milliseconds
Number of tests: 1000
Performance: 4.466666666666667 O(N) nanoseconds
Performance: 0.30032705633819357 O(N*Log2(N)) nanoseconds
Performance: 1.488888888888889E-4 O(N*N) nanoseconds

The performance of this implementation is somewhat between quicksort and merge sort.

Last update: 2011.

Table of Contents

 About This Book

 Introduction of Sorting Algorithms

 Java API for Sorting Algorithms

 Insertion Sort Algorithm and Implementation

 Selection Sort Algorithm and Implementation

 Bubble Sort Algorithm and Implementation

 Quicksort Algorithm and Implementation

 Merge Sort Algorithm and Implementation

Heap Sort Algorithm and Implementation

 Heap Sort - Algorithm Introduction

 Heap Sort - Java Implementation

Heap Sort - Performance

 Heap Sort - Implementation Improvements

 Shell Sort Algorithm and Implementation

 Performance Summary of Java Implementations

 References

 PDF Printing Version