Re: Worst-case Performance of Insertion Sort
- From: "NUPUL" <nupul.kukreja@xxxxxxxxx>
- Date: 20 Feb 2007 23:37:15 -0800
On Feb 21, 9:58 am, "eKo1" <berndlos...@xxxxxxxxxxxx> wrote:
I'm asked to find another class of input that produces the worst-case
behaviour of this algorithm but I just can't think of another one. Any
hints or tips as to what that other input class might look like?
let's see:
Set1:
9 8 7 6 5 1 2 3 4 (descending+ascending)
Set2:
1 9 2 8 3 7 4 6 5 (interleaved)
Set3:
Completely randomized input (NOT producing nearly sorted output)
Basically worst-case bound is "asymptotic" and will occur only when
the input is sorted in decreasing order.
Insertion sort works extremely well on "nearly sorted inputs" the rest
of the combinations all *tend to* O(n^2) (asymptotically). Have a look
at the text of "Introduction to algorithms: Cormen" for a better
insight
Regards,
Nupul
.
- Follow-Ups:
- Re: Worst-case Performance of Insertion Sort
- From: eKo1
- Re: Worst-case Performance of Insertion Sort
- References:
- Worst-case Performance of Insertion Sort
- From: eKo1
- Worst-case Performance of Insertion Sort
- Prev by Date: Re: Doubt
- Next by Date: Re: Do Write Once TM's Halt?
- Previous by thread: Worst-case Performance of Insertion Sort
- Next by thread: Re: Worst-case Performance of Insertion Sort
- Index(es):
Relevant Pages
|