
Patrick B. answered 11/21/20
Math and computer tutor/teacher
I have given you the code for the quicksort and the binary search...
to add a new record to the array, do something like this:
InsertAddnew( int * A, int n, int iNewIntNum)
{
int iReturn=0;
if (n<MAX_CAPACITY)
{
A[n++] = iNewIntNum;
qsort(A,n,sizeof(int),compareInt);
}
else
{
iReturn=-1; //array is full
}
}
yes you can do a 1-pass insertion sort which is ARGUABLY faster than
quicksort on almost sorted arrays, but I don't feel like racking my brains
for deletion, since the array is already sorted, just move
all of the elements GREATER than the target one position
to the left, and then decrement the size