473,396 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Introsort

Can someone tell me why Musser's Introsort algorithm switches
to Heapsort when the recursion depth of Quicksort gets too
large. Wouldn't Mergesort be a better choice? It's faster
than Heapsort, isn't it? I know Mergesort does not work in
O(1) additional space, the way Heapsort does, but neither
does Quicksort, so we don't seem to be gaining anything.

(Yeah, this isn't about C++, but there doesn't seem to be
any "comp.algorithms" group ... or anything of a similar
nature.)

-- Matt

Jul 23 '05 #1
1 5314
In article <11*********************@z14g2000cwz.googlegroups. com>,
Matt Bitten <mb*******@yahoo.com> wrote:
Can someone tell me why Musser's Introsort algorithm switches
to Heapsort when the recursion depth of Quicksort gets too
large. Wouldn't Mergesort be a better choice? It's faster
than Heapsort, isn't it? I know Mergesort does not work in
O(1) additional space, the way Heapsort does, but neither
does Quicksort, so we don't seem to be gaining anything.
Mergesort requires O(n) space for a copy of the data, which can get
expensive for large amounts of data or large data items. Quicksort-
with-depth-limit only requires O(lg n) additional space, and only for
index values, with no additional space required for a copy of the data.
Anything that can sort in-place (with or without space requirements
for activation records) tends to be a pretty big win space-wise over
algorithms that require working space for a copy of the data.

(Yeah, this isn't about C++, but there doesn't seem to be
any "comp.algorithms" group ... or anything of a similar
nature.)


comp.programming is a good place to discuss the practical implications
of algorithms. Crossposted and followups set.
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca

Your assertion is noted. I disagree entirely with it.
--Richard Heathfield in comp.lang.c
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pavel Pluhacek | last post by:
Does anybody know how is working generic std::sort function in stlport? I've tried to go through source code but it's too complex and not commented. I've tried to write as fast algorithm as I...
16
by: Kitty | last post by:
Hi, everyone. Given a vector<int>, what is the fastest way to find out whether there is a repeated element in it? The result is just "true" or "false". Thanks. Kitty
3
by: PWalker | last post by:
Hi, I have written code that I would like to optimize. I need to push it to the limit interms of speed as the accuracy of results are proportional to runtime. First off, would anyone know any...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
5
by: Am | last post by:
hi i came to know that microsoft improved the efficiency of quick sort by using a cutoff of 8 elements and continuing with insertion sort then, do anybody have the details about it please...
75
by: At_sea_with_C | last post by:
Hello all, I have written an ascending sort routine for floats. This seems to do the job, but for elements over 10,000, it gets awfully slow. A lot of useless comparisions with previously sorted...
10
by: ikarus | last post by:
Hello C++ Gurus! I'm comparing sorting algorithm for study goals. I've compared STL std::sort and hand-coded introsort on millions (tens of millions) of integers array sorting. It was tested...
84
by: s0suk3 | last post by:
The task: Write a program that reads a set of words from standard input and prints the number of distinct words. I came across a website that listed a few programs to accomplish this task:...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.