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 6679187
In Process

The Archive Base Latest Questions

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

I am trying to write a program for selection sort of the elements an

  • 0

I am trying to write a program for selection sort of the elements an array in C++ (VS2010) using recursion. The program works without any issues for for smaller arrays where the size of the array is less than 10 when I increase the size of the array to 10000 I am facing stackoverflow exception. How do I go about resolving this?

Thank you for the answers so far. My idea is not to sort the array but to sort a large array using recursion and the hit a stackoverflow exception. My main idea behind this exercise is to learn ways to resolve the stackoverflow exception rather than sorting the array.

selectionSortRecursive(int a[], int startindex, int endindex)
{
    if (startindex<endindex)
    {
        int s = startindex;
        for (int index=startindex+1;index<endindex;index++)
        {
            if (a[s]>a[index])
                s=index;
        }
        if (s>startindex)
        {
            a[s]=a[startindex]+a[s];
            a[startindex]=a[s]-a[startindex];
            a[s]=a[s]-a[startindex];
        }
        selectionSortRecursive(a, startindex+1, endindex);
    }

}
  • 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-26T04:19:50+00:00Added an answer on May 26, 2026 at 4:19 am

    Either increase the size of the stack (which can be done with the STACK linker option) or — and this is a much better option — improve or replace your algorithm. It sounds like a recursive algorithm may not be suitable for the kind of data you need to process, but maybe you can improve things by using fewer local variables and/or parameters in each method invocation, to make the stack frames smaller.

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

Sidebar

Related Questions

I'm trying to write a resolution selection dialog that pops up when a program
I'm trying to write a program that cleans data, using Matlab. This program takes
I'm trying to write program calculating average of given numbers stored in an array.
I trying to write a program that navigates the local file system using a
I'm trying to write a program to process the BSD-style process accounting file under
I'm trying to write a program that uses sockets to connect with other instances
I'm trying to write a program in C (on Linux) that loops until the
I'm trying to write a program that reads text from external file (string string
I am trying to write a program that allows a binary to be run,
I'm trying to write a program in Python and I'm told to run an

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.