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

  • SEARCH
  • Home
  • 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 7061555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:29:19+00:00 2026-05-28T04:29:19+00:00

Can anyone point out why this implementation of quick sort is not working, i

  • 0

Can anyone point out why this implementation of quick sort is not working, i have gone through it several times and can’t seem to find the error

int quickPartition ( int data[], int p, int r)
{
    int x=data[r];
    int i=p-1;
    for (int j=p; j<r; j++)
    {
        if(data[j]<x)
        {
            i++;
            int temp=data[i];
            data[i]=data[j];
            data[j]=temp;
        }
        int temp=data[i+1];
        data[i+1]=data[r];
        data[r]=temp;   
    }
    i++;
    cout<<"i:"<<i<<endl;
    return i;
}

void myQuickSort(int data[], int left, int right)
{       
    if(left<right)
    {
        int q=quickPartition(data,left,right);
        myQuickSort(data,left,q-1);
        myQuickSort(data,q+1,right);
    }
}

the call to quicksort is simply

myQuickSort(anArray,0,size-1);
  • 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-05-28T04:29:20+00:00Added an answer on May 28, 2026 at 4:29 am

    Methinks

        int temp=data[i+1];
        data[i+1]=data[r];
        data[r]=temp;
    

    should go outside the for loop.

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

Sidebar

Related Questions

Can anyone please point out what im doing wrong with this Stored Procedure please.
Please can anyone point out my mistake in this: String j = SELECT +
Can anyone point me out, how can I parse/evaluate HQL and get map where
Can anyone point me in the right direction on this. From reading the FAQs
I'm asking this questions out of curiostity, since my quick and dirty implementation seems
Can anyone point out an extension where we can add articles in another language,
I want to try out SICP with Python. Can any one point to materials
Can anyone point me to a good resource (or throw me a clue) to
Can anyone point me to a good introduction to coding against the paypal API?
Can anyone point me to a tutorial on the best way to open a

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.