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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:30:05+00:00 2026-06-13T01:30:05+00:00

I have an application that performs a quick sort. It was working fine till

  • 0

I have an application that performs a quick sort. It was working fine till I started handing it some bigger numbers (I first got it at 10000000). I understand that a Stackoverflow is caused by recursion but I can’t understand why my application would be bombing out due to it. Any advice would be appreciated. Here’s my code:

class quickSort
{
    const int NOOFELEMENTS = 10000000;
    // this is our array to sort
    private int[] arr = new int[NOOFELEMENTS];

    // this holds a number of elements in array
    private int len;

    // Quick Sort Algorithm
    public void QuickSort()
    {
        sort(0, len - 1);
    }

    public void sort(int left, int right)
    {
        int pivot, l_holder, r_holder;

        l_holder = left;
        r_holder = right;
        pivot = arr[left];

        while (left < right)
        {
            while ((arr[right] >= pivot) && (left < right))
            {
                right--;
            }

            if (left != right)
            {
                arr[left] = arr[right];
                left++;
            }

            while ((arr[left] <= pivot) && (left < right))
            {
                left++;
            }

            if (left != right)
            {
                arr[right] = arr[left];
                right--;
            }
        }

        arr[left] = pivot;
        pivot = left;
        left = l_holder;
        right = r_holder;

        if (left < pivot)
        {
            sort(left, pivot - 1);
        }

        if (right > pivot)
        {
            sort(pivot + 1, right);
        }
    }

    public static void Main()
    {
        quickSort q_Sort = new quickSort();

        int[] arr = new int[NOOFELEMENTS];

        Random rnd = new Random();
        for (int i = 0; i < NOOFELEMENTS; i++)
        {
            arr[i] = rnd.Next(0, 1000);
        }
        q_Sort.arr = arr;
        q_Sort.len = q_Sort.arr.Length;

        var startTime = DateTime.Now;

        // Sort the array
        q_Sort.QuickSort();

        Console.WriteLine("Total Time: {0}\n", DateTime.Now - startTime);

    }
}
  • 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-13T01:30:06+00:00Added an answer on June 13, 2026 at 1:30 am

    Well. Your code will recurse between log2 10000000 and 10000000 levels deep.

    Depending on tail-recursion optimizations in the compiler (if any) that can use a lot of stackspace.

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

Sidebar

Related Questions

I have an application written in Java that performs some straightforward but time consuming
I have a simple little application that performs some analysis of all our corporate
I have an ASP.Net application that performs some database initialization during Application_Start in Global.asax.
I have developed an Android application that performs some network activity. Inside the classes
I have a simple Swing Java application that performs searches, and the results are
We have an application that performs auto-updates. Until recently, we haven't run into any
I have an Android application that I've been working on, and it's implemented using
I have a Google App Engine application that performs about 30-50 calls to a
I created a Windows Qt C++ application that performs some SQL queries. This application
I have a form application that performs a simulation and constantly reads/writes a binary

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.