Question: Implement in C / C + + a divide and conquer algorithm that computes the number of pairs of adjacent equal elements in an array

Implement in C/C++ a divide and conquer algorithm that computes the number of pairs of adjacent equal elements in an array of integer values. The algorithm should run in theta(nlogn) in the average case.
For instance, for the array [333244] there are the following adjacent pairs with identical elements (shown in parentheses): [(33)3244],[3(33)244] and
[3332(44)]. Show how your algorithm runs on the following
input: A =[1224556773338988]. After each combine step, and
before returning from the recursive call, your algorithm should print the following: 1) the array that was used as input for the current call, and 2) the number of pairs computed for that input. Note: Submit your source code (in a file named problem1.c or problem1.cpp) as well as an image with the program output (in a file named output1, with JPG or PDF extension).

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!