Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago