Jump to content
  • Advertisement
  • 09/13/99 06:20 PM
    Sign in to follow this  


    General and Gameplay Programming

    Myopic Rhino
    Now that we visit a recursive sorting algorithm. This algorithm involves moving a data, called pivot. The algorithm then partitions the array into two parts by moving the pivot into its correct position, so that items to the pivot's left are smaller then the pivot, and the items to the right are bigger.The algorithm then is called recursively so that it will partition the two subordinate arrays on either side of the pivot until the entire array is sorted.

    Below is the pseudo-code of Quick Sort.

    Quick Sort (Sorting array A[size])

    While Low is less than High
    Choose Pivot as the element at position A[Low]
    While A[High] is greater than Pivot, decrement High; else move A[High] to A[Low]
    While A[Low] is less than Pivot, increment Low; else move A[Low] to A[High]
    Move Pivot into A[High], see Pivot position as High.
    If Low is less than Pivot point, recursively call Quick Sort with Low =
    Low, High = Pivot point - 1
    If High is greater than Pivot point, recursively call Quick Sort with Low =
    Pivot point + 1, High = High.

      Report Article
    Sign in to follow this  

    User Feedback

    Create an account or sign in to leave a review

    You need to be a member in order to leave a review

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    There are no reviews to display.

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!