From c728a1204a62846be24a5cfda23c61ce3eecb91a Mon Sep 17 00:00:00 2001 From: nickysn Date: Tue, 5 Feb 2019 18:25:27 +0000 Subject: [PATCH] + added additional notes in the comments for HeapSort git-svn-id: trunk@41233 - --- packages/rtl-extra/src/inc/sortalgs.pp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/rtl-extra/src/inc/sortalgs.pp b/packages/rtl-extra/src/inc/sortalgs.pp index f79111df56..85f9ed50d0 100644 --- a/packages/rtl-extra/src/inc/sortalgs.pp +++ b/packages/rtl-extra/src/inc/sortalgs.pp @@ -31,6 +31,20 @@ uses Worst performance: O(n log n) Extra memory use: O(1) Stable: no + Additional notes: Usually slower in practice, compared to QuickSort (in the + average case), but has a much better worst-case + performance of O(n log n) (versus O(n*n) for QuickSort). + Can be used instead of QuickSort where the risk of + QuickSort's worst case scenario is not acceptable - e.g. + high risk applications, security-conscious applications + or applications with hard real-time requirements. + + On systems with small or no data caches it might perform + better or comparable to QuickSort even in the average + case, so might be a good general purpose choice for + embedded systems as well. It's O(1) extra memory use and + the fact it's not recursive also makes it a good + candidate for embedded use. } procedure HeapSort_PtrList_NoContext(