CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2012
    Posts
    54

    Qucik Sort Uisng last element as Pivot

    hello
    can anyone explain quick sort example using last element as pivot element. I know how to sort element using first and middle element as pivot element.

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Qucik Sort Uisng last element as Pivot

    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Jan 2012
    Posts
    54

    Re: Qucik Sort Uisng last element as Pivot

    i know that process but when first partition is done means elements which is less than pivot is in left side and elements which is greater than pivot is in right side of pivot.
    but what is the other process when this is done. when i take example and trace this step i m confused..SO can you explain with example?

  4. #4
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Qucik Sort Uisng last element as Pivot

    Well, if you think about it: if you know how to do the partition with the first or the middle element as the pivot, then to do the partition with the last element as the pivot, just swap it with the first or middle element then do what you already know.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured