Computer Science, asked by prnikabakshi, 6 hours ago

Programming challenge description: The Cartesian product of two lists of numbers A and B is defined to be the set of all points (a,b) where a belongs in A and b belongs in B. It is usually denoted as A x B, and is called the Cartesian product since it originated in Descartes' formulation of analytic geometry. Given two sets of real numbers, their Cartesian product comes in form of ordered pairs. e.g. A = [1, 2, 3] B = [4, 5] Cartesian product is C = [(1, 4), (1, 5), (2,4), (2.5), (3,4), (3,5)] Now given a coordinate tuple (i,j), where i indicates A[i] and j indicates B[j], with A, B known, implement a function that returns the index of a member in Cartesian product C according to (i,j) For example: coordinate (1, 0) return index: 2 coordinate (2, 1) return index: 5 The time complexity of this algorithm should be O(1)

Answers

Answered by swati5321
0

Explanation:

The Cartesian product of two lists of numbers A and B is defined to be the set of all points (a,b) where a belongs in A and b belongs in B. It is usually denoted as A x B, and is called the Cartesian product since it originated in Descartes' formulation of analytic geometry.

Similar questions