Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:21:29+00:00 2026-06-09T15:21:29+00:00

I am trying to study various sorting and searching algorithms for an upcoming test

  • 0

I am trying to study various sorting and searching algorithms for an upcoming test this Tuesday. All went well until I got to the Quick Sort Algorithm. I did not have a book or any other resource, so I went online and started reading the SparkNote. I thought I understood the text, and I even read the Quick Sort Algorithm part of a PowerPoint I found online.

However, SparkNote provided an example on the page of the step-by-step process of the algorithm, but it did not show the steps to initially arrange the list. The list given was [5 9 3 8 6 4 2 1 7 0]. According to SparkNotes, the arranged list, with the values less than the pivot (which is 5) on the left and the values greater than the pivot on the right, is [0 3 4 2 1 5 8 6 7 9]. However, when I try to go through the steps myself, I keep getting [ 4 0 3 1 2 5 6 8 7 9 ].

The procedure I took was:

5 9 3 8 6 4 2 1 7 0 // The initial list. Pivot = 5
5 0 3 8 6 4 2 1 7 9 // Switched 0 and 9.
5 0 3 1 6 4 2 1 7 9 // Switched 8 and 1
5 0 3 1 2 4 6 8 7 9 // Switched 6 and 2
4 0 3 1 2 5 6 8 7 9 // Switched 4 and 5 because the lines that point to the 
                    // greater and smaller numbers crossed.

Where is my mistake? Also, I see that the numbers less than 5 are on the left and the numbers greater than 5 are on the right, so, does my mistake really affect the sorting?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:21:30+00:00Added an answer on June 9, 2026 at 3:21 pm

    The algorithm described in SparkNotes initially places the pivot element to the rightmost position in the array. The algorithm you used placed/kept the pivot to the leftmost position. No wonder the arrangements after partitioning are different.

    That means that they started with

    5 9 3 8 6 4 2 1 7 0
    

    chose 5 as pivot and placed it in the rightmost position (exchanged 5 and 0)

    0 9 3 8 6 4 2 1 7 5
    

    and only after that they performed partitioning for the remaining elements.

    You kept your 5 in the leftmost position (apparently you simply forgot to do step 2 from SparkNotes). In the end, both variants work, i.e. there’s no “mistake”. In your case the arrangement is perfectly valid with the array correctly partitioned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've been trying to study for my finals by practicing classes and inheritance, this
I am trying to study for a test where I have to know something
I'm trying to study for my exam and I thought I was doing this
I am trying to implement a subset of Java for an academic study. Well,
Ok, i'm a newbie in this, i've been trying to study MVC patterns and
Trying to study C++ function templates. As a part of which I have this
I've been trying to study datastrucutres and algorithms for many times and I feel
I am trying to learn Django and for this I would like to study
I'm trying to study for a basic SQL test at school but unfortunately I
I am studying C++ now. I am trying to study it from this link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.