Question: Implement 2 minimum subsequence algorithms and show the execution result using 20 random integer numbers in the range of -100 to 100. here are the

Implement 2 minimum subsequence algorithms and show the execution result using 20 random integer numbers in the range of -100 to 100.

here are the example of 2 algorithms:(here is maximum but we are asked to find the minimum)

Implement 2 minimum subsequence algorithms and show the execution result using 20

random integer numbers in the range of -100 to 100. here are

RULES:

1.Use int for data type of function

2.The parameters consist of four:

seq: array for input sequence

seq_length: length of the input sequence

Low: First node number of the minimum subsequence

High: Last node number of the minimum subsequence

3.Obtain the minimum sum found in the function as the return value

Calculate algorithm performance time:

Inputs: no. of sequences, length of each sequence

Creating an input sequence using a random number generator according to the value of length

Output- sequence itself , low , high , minimum sum, running time

the example of 2 algorithms:(here is maximum but we are asked to

#include

#include

#include

#include

#include

int MinSubsequenceSum1(const int A[], int N, int *high, int *low)

{

int ThisSum = 0, MinSum = 10000;

for (int j = 0; j

{

//your code

}

return MinSum;

}

int MinSubsequenceSum2(const int A[], int N, int *high, int *low)

{

int ThisSum = 0, MinSum = 10000;

for (int j = 0; j

{

//your code

}

return MinSum;

}

int main()

{

LARGE_INTEGER start, end, time_unit;

int seq[1000];

int seq_count = 0;

int high = 0, low = 0;

int seq_length = 0;

int result = 0;

//Validation

printf("Two extreme dataset for testing your program ");

int positive_seq[10] = { 11,12,4,8,10,14,16,18,2,21 };

int negative_seq[10] = { -8,-15,-16,-3,-9,-18,-7,-11 ,-19,-6 };

result = MinSubsequenceSum2(positive_seq, 10, &high, &low);

printf(" positive_seq:");

for (int i = 0; i

{

printf("%4d", positive_seq[i]);

}

printf(" low=%d,high=%d,result=%d ", low, high, result);

high = 0, low = 0;

result = MinSubsequenceSum2(negative_seq, 10, &high, &low);

printf(" negative_seq:");

for (int i = 0; i

{

printf("%4d", negative_seq[i]);

}

printf(" low=%d,high=%d,result=%d ", low, high, result);

//repeat above steps for your second program

printf("your programs have passed our basic test ");

//*************************************************

high = 0; low = 0;

printf("Enter the number of sequences:");

scanf_s("%d", &seq_count,sizeof(seq_count));

fflush(stdin);

for (int i = 0; i

{

printf("Enter the length of the sequence in the incteasing order:");

scanf_s("%d", &seq_length,sizeof(seq_length));

fflush(stdin);

srand((unsigned)time(NULL));

for (int j = 0; j

{

int random = rand() % 200 - 100;

seq[j] = random;

printf("%4d", seq[j]);

}

printf(" ");

printf(" ******** Your first program *********** ");

QueryPerformanceFrequency(&time_unit);

QueryPerformanceCounter(&start);

result = MinSubsequenceSum1(seq, seq_length, &high, &low);

printf("low=%d,high=%d,result=%d ", low, high, result);

QueryPerformanceCounter(&end);

printf("running time=%f s ", (double)(end.QuadPart - start.QuadPart) / (double)time_unit.QuadPart);

printf(" ");

printf(" ******** Your second program ************ ");

QueryPerformanceFrequency(&time_unit);

QueryPerformanceCounter(&start);

result = MinSubsequenceSum2(seq, seq_length, &high, &low);

printf("low=%d,high=%d,result=%d ", low, high, result);

QueryPerformanceCounter(&end);

printf("running time=%f s ", (double)(end.QuadPart - start.QuadPart) / (double)(time_unit.QuadPart));

printf(" ");

}

_getch();

}

Maximum subsequence sum algorithm 1 MaxSubsequenceSum( const int AL ], int N) int ThisSum, MaxSum, i, j, k; MaxSum = 0; for(-0; i MaxSum) 8* MaxSum = Th sSum; return MaxSum

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!