Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Multi Dimensional Selection Given a 2-d array arr of size nm, a selection is defined as an array of integers such that it contains

image text in transcribed
image text in transcribed
image text in transcribed
5. Multi Dimensional Selection Given a 2-d array arr of size nm, a selection is defined as an array of integers such that it contains at least m/27 integers from each row of arr. The cost of the selection is defined as the maximum difference between any two integers of the selection. Suppose k is the minimum cost of all the possible selections for the given 2-d array. Find the maximum value of the product of k the number of integers considered in the selection with the minimum cost. Example Suppose n=3,m=2, and arr =[[1,2],[3,4],[8,9]] Some of the possible selections are [2,3,8],[1;2,3,9], [1,3,4,8,9] etc. The cost of these selections are 82= 6,91=8, and 8 respectively. Here the minimum cost of all the possible selections is 6. The possible selections with the cost 6 are [2,4,8] and [2,3,4,8]. The maximum value of the required product is obtained using the latter selection i.e. 64 =24. Hence the answer is 24 . Function Description Complete the function getMaxProduct in the editor below. Function Description Complete the function getMaxProduct in the editor below. getMaxProduct has the following parameter: int arr[n][m]: the given 2-d array Returns int: the maximum possible product Constraints - 1n103 - 2m103 - 1arr[i][j]109 - Input Format For Custom Testing The first line contains an integer, n, which denotes the number of rows in arr. The second line contains an integer, m, which denotes the number of columns in arr. Each line i of the n subsequent lines (where 0i

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

Database Theory Icdt 99 7th International Conference Jerusalem Israel January 10 12 1999 Proceedings Lncs 1540

Authors: Catriel Beeri ,Peter Buneman

1st Edition

3540654526, 978-3540654520

More Books

Students also viewed these Databases questions