1. In this problem, you are required to write a program to implement the ClosestPair algorithm

2. In this problem, you are required to write a program to implement the LongestCommonSubsequence algorithm

Once your program in implemented, you can demonstrate that it works using the sequences
X = <s, k, u, l, l, a, n, d, c, r, o, s, s, b, o, n, e, s>
Y = <l, u, l, l, a, b, i, e, s, f, o, r, b, a, b, i, e, s>.

3. In this problem, you are required to write a program to implement the NaïveBayes algorithm

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.


PointPair ClosestPair(vector<pair<int, int> > &pX, vector<pair<int, int> > &pY, int n)
vector<pair<int, int> > pXL, pXR, pYL, pYR, pYC;
PointPair clPL, clPR, clP;
int j, k;
double minDistance;

// if the number of points is not greater than 3, find closest pair by brutal force
if (n <= 3)
clP = BruteForce(pX, n);
int middle = (n - 1) / 2; // the element in the middle of the array
int x = pX[middle].first;
int y = pX[middle].second;
// split the array in two
// make the first half array
for (int i = 0; i <= middle; i++)
pXL[i] = pX[i];
j = 0;
// make the second half array
for (int i = middle + 1; i < n; i++)
pXR[j] = pX[i];
j = 0;
k = 0;

//split the other array to two
for (int i = 0; i < n; i++)
// put in first array the points where x is less than in middle element, or same with y not greater than the middle elements and the number of elements in first array is less than the half of number of all elements
if ((pY[i].first < x) || ((pY[i].first == x) && (pY[i].second <= y) && (j <= middle)))
pYL[j] = pY[i];
else // else put point to the second array
pYR[k] = pY[i];
clPL = ClosestPair(pXL, pYL, j); // call the function recursivaly with left points
clPR = ClosestPair(pXR, pYR, k); // call the function recursivaly with right points
clP = MinPair(clPL, clPR); // find the minimum distance comparing the minimum distances returned from recursive calls
minDistance = distance(clP.p1, clP.p2);
// make an array with points closer than minimum distance to the splitting line
for (int i = 0; i < n; i++)

By purchasing this solution you'll be able to access the following files:

50% discount

$25.00 $12.50
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats