Question: PLEASE HELP ME TO COMPLETE MY C++ CODE FOR THIS FUNCTION IN THE // function to be implemented by you #include #include #include using namespace

 PLEASE HELP ME TO COMPLETE MY C++ CODE FOR THIS FUNCTION

PLEASE HELP ME TO COMPLETE MY C++ CODE FOR THIS FUNCTION IN THE "// function to be implemented by you"

#include

#include

#include

using namespace std;

// -------------------------------------------- functions to be implemented by you

void filter_1(int *a, int& n, int countThreshold)

{

// Input array a[] is not ordered.

// Remove numbers in a[] that appear less than countThreshold number of times.

// Relative order of elements retained in the array need not be preserved.

// Do NOT sort the array a[] in your answer.

}

void filter_2(int *a, int& n, int countThreshold)

{

// Input array a[] is sorted in ascending order.

// Remove numbers in a[] that appear less than countThreshold number of times.

// Relative order of elements retained in the array should be preserved.

}

// ------------------------------------------- functions given to you

void printArray(const char *header, int* a, int n)

{

cout

for (int i = 0; i

{

if (i > 0 && i % 10 == 0)

cout

cout

}

cout

}

void test_1(const char *header, int *a, int& n, int threshold)

{

cout

printArray(header, a, n);

cout

filter_1(a, n, threshold);

printArray(header, a, n);

}

void part_1()

{

cout

int a[] = {1, 2, 3, 3, 1, 4, 4, 4, 5, 8, 6, 6, 5, 5, 2, 5, 5, 1, 7, 7};

int n = 20;

test_1("a[]", a, n, 3);

int b[] = {1, 3, 2, 4, 3, 2, 6, 7, 8, 7};

int m = 10;

test_1("b[]", b, m, 3);

int c[] = {1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 2, 1, 2, 2, 1, 1, 0};

int r = 20;

test_1("c[]", c, r, 5);

}

void test_2(const char *header, int *a, int& n, int threshold)

{

cout

printArray(header, a, n);

cout

filter_2(a, n, threshold);

printArray(header, a, n);

}

void part_2()

{

cout

cout

int a[] = {1, 1, 2, 2, 2, 2, 5, 5, 6, 6, 7, 7, 7, 9, 9, 9, 10, 12, 13, 13};

int n = 20;

test_2("a[]", a, n, 3);

int b[] = {1, 1, 2, 2, 3, 4, 6, 7, 7, 8};

int m = 10;

test_2("b[]", b, m, 3);

int c[] = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};

int r = 20;

test_2("c[]", c, r, 5);

}

int main()

{

part_1();

part_2();

system("pause");

return 0;

}

-ox ID: Work\TEACH\EE2331 - C-Plus-Plus 2020-01\Project-2020-01\Debug Project-2020-01.exe Part_1: Unordered array a[], size = 20 1, 2, 6, 6, 3, 5, 3, 5. 1, 2. 4, 5, 4, 5, 4, 1. 5, 7. 8, 7. Remove numbers that appear less than 3 times. a[], size = 11 1, 1, 5, 5, 1, 4, 4, 4, 5, 5, 5, - , 8, 7, b[], size = 10 1, 3, 2, 4, 3, 2, 6, 7, Remove numbers that appear less than 3 times. b[l, size = 0 C[], size = 20 0, 1, 1, 2, 1, 2, 2, 1, 1, 0, Remove numbers that appear less than 5 times. c[], size = 13 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

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!