Question: Given an array; write a function to find out the repeating number with the longest count. You can use the below code and fill the

Given an array; write a function to find out the repeating number with the longest count. You can use the below code and fill the code for the function "computeLongestSequence" . Your program should output something like:

Longest repeating number is:1 with count:1

Longest repeating number is:3 with count:4 Longest repeating number is:3 with count:4 Longest repeating number is:3 with count:10

The above statements will be written inside the function "computeLongestSequence" .

The first line could have the number 1 or some other number also depending on your code as the first array has all different elements.

#include using namespace std ; /* The function "computeLongestSequence" prints the longest sequence of a repeating number. If there is more than 1 repeating sequence then any number can be the answer. The function should print the following for each invocation of the array and size. Longest repeating number is: ( repeating number) with count ( count of the number) */ void computeLongestSequence( int arrayOfNumbers[] , int size ) { } int main() { /* int arr5[] = {1 , 2 , 3, 3 }; computeLongestSequence( arr5 , 4 ) ; exit(0); */ const int SIZE=10 ; int arr1[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } ; int arr2[10] = { 1, 2, 3, 3, 3, 3, 7, 7, 9, 10 } ; int arr3[10] = { 2, 2, 3, 4, 5, 6, 3, 3, 3, 3 } ; int arr4[10] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } ; computeLongestSequence( arr1 , SIZE ) ; computeLongestSequence( arr2 , SIZE ) ; computeLongestSequence( arr3 , SIZE ) ; computeLongestSequence( arr4 , SIZE ) ; return(0) ; } You can use the initial code in "main" function to debug your application.

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!