best sorting method to sort half end of array

This is a discussion on best sorting method to sort half end of array within the C Programming forums, part of the General Programming Boards category; hi,I want to sort a array a[10000] of which first 5000 elements are stored in sorted order,and I want to ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    28

    best sorting method to sort half end of array

    hi,I want to sort a array a[10000] of which first 5000 elements are stored in sorted order,and I want to sort last 5000 elements.So tell me which sorting algorithm will be best so that my complexity is minimum.
    I dont think so quick sort is good to do this task.
    Thank You,
    Nitin.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,556
    > I dont think so quick sort is good to do this task.
    quicksort the 2nd half, then mergesort both halves.

    Or just quicksort the whole lot without any more thought and find something else more important which needs doing, until you know for sure that this is actually a performance bottleneck.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,304
    Try sorting the second half and then merging it with the first half.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. two dimensional array sorting in C/C++
    By George2 in forum C Programming
    Replies: 16
    Last Post: 11-19-2006, 02:17 AM
  3. for loop with sort issues
    By redmondtab in forum C Programming
    Replies: 10
    Last Post: 10-09-2006, 10:36 AM
  4. Sorting: Getting permutation index array
    By flyvholm in forum C Programming
    Replies: 2
    Last Post: 09-20-2006, 07:07 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21