Home > Back-end >  For quick sort algorithm, 0 xc00000fd: Stack overflow (x00282f9c x00000001 parameters: 0, 0).
For quick sort algorithm, 0 xc00000fd: Stack overflow (x00282f9c x00000001 parameters: 0, 0).

Time:10-09

The first chance to abnormal 0 x00191879 (in QuickSort. Exe) :
0 xc00000fd: Stack overflow (x00282f9c x00000001 parameters: 0, 0),
If there are suitable for this exception handler, the program will continue to run safely,

//quick sort algorithm, don't know why, my code to not only sorting sorted array
//for the already sorted array, int a [MAX_SIZE], if you define smaller than MAX_SIZE, call Quick_Sort function is no problem, but if you define MAX_SIZE is larger, the program will appear the error

# include & lt; Iostream>
# include & lt; Iomanip>
using namespace std;

# define MAX_SIZE 10000
Template
Void Quick_Sort (T * a, int left, int right);

Int main ()
{

An int array [MAX_SIZE];
for(int i=0; IArray [I]=I;
Quick_Sort (array, 0, MAX_SIZE - 1);

System (" pause ");
return 0;
}

Template
A void Quick_Sort (T * and an int left, int right)
{
Int I=left, j=right;
T base=* (a + left);
If (right<=left)
return ;
While (i{
While (ij--;
If (i* (a + I)=* (a + j);
While (ii++;
If (i* (a + j)=* (a + I);
}

If (I==j)
* (a + I)=base;
Quick_Sort (a, left, I - 1);
Quick_Sort (a, I + 1, right);
}


CodePudding user response:

Stack overflow, is often caused by dead recursion

CodePudding user response:

Recursive calls, use the Stack, and the size of the Stack is designated by the build system commonly, is not very big, so will Stack overflow
Therefore, to deal with large data, do not use recursion

CodePudding user response:

But I call this function does not appear below the case, can you help me explain?
Void tree (int v [], int left, int right)
{
Int I, the last;
Void swap (int v [], int, int j);
If (left & gt;=right)
return;
The last=left;
For (I=left + 1; I & lt;=right; I++)
If (v [I] Swap (v + + last, I);
Swap (v, left, the last);/* restore partition elem */
Tree (v, left, the last - 1);
Tree (v, last + 1, right);
}

Void swap (int v [], int, int j)
{
int temp;
Temp=v [I];
V=v [I] [j];
V [j]=temp;
}

CodePudding user response:

This is the same number and recursive algorithm, a stack overflow, another is not the case

CodePudding user response:

Typography is not?

CodePudding user response:

What layout??