Thread: best sorting method to sort half end of array

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > 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.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    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, 09:35 AM
  2. two dimensional array sorting in C/C++
    By George2 in forum C Programming
    Replies: 16
    Last Post: 11-19-2006, 03: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