subject
Computers and Technology, 08.07.2021 18:40 chavez0

Cartesian Product 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 (1-12 where indicates A[1] and indicates B) with A, B known, implement a function that returns the index of a member in Cartesian product Caccording to (10)
For example:
coordinate (1, 0)
return index: 2
coordinate (2, 1)
return index: 5
The time complexity of this algorithm should be (1)
Input:
• real number set
• real number set
• coordinate tutple (1,1)
Output:
Index of a member in AX B (Cartesian product of A and B)
If inputs are invalid, return -1
• real number set A
• real number set B
• coordinate tutple (1,1)
Output:
Index of a member in AX B (Cartesian producto
If inputs are invalid, return-1
Test 1
Test Input
['a', 'b', 'c')
[1,2,3]
(0, 1)
Expected Output
-1
Test 2
Test Input
[1, 2, 3]
[4, 5]
(2, 1)
Expected Output
5
Test Input
[1, 2, 3]
[4, 5]
(2, 1)
Expected Output
5
Test 3
Test Input
[1, 2, 3]
[4, 5]
(1, 0)
Expected Output
2

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:00, Ltik11900
Write the command that can be used to answer the following questions. (hint: try each out on the system to check your results.) a. find all files on the system that have the word test" as part of their filename. b. search the path variable for the pathname to the awk command. c. find all files in the /usr directory and subdirectories that are larger than 50 kilobytes in size. d. find all files in the /usr directory and subdirectories that are less than 70 kilobytes in size. e. find all files in the / directory and subdirectories that are symbolic links. f. find all files in the /var directory and subdirectories that were accessed less than 60 minutes ago. g. find all files in the /var directory and subdirectories that were accessed less than six days ago. h. find all files in the /home directory and subdirectories that are empty. i. find all files in the /etc directory and subdirectories that are owned by the group bin."
Answers: 1
image
Computers and Technology, 23.06.2019 16:30, 19thomasar
How to do this programming flowchart?
Answers: 3
image
Computers and Technology, 24.06.2019 03:30, mprjug6
Which explains extrinsic motivation? a)motivation in which there is a reward b)motivation that is personally satisfying c)motivation that is personally meaningful d)motivation in which the subject is interesting
Answers: 1
image
Computers and Technology, 25.06.2019 00:00, tori3981
When pasting an existing chart into a word document, you can choose to using the paste options button. a. paste the chart as a picture b. embed the chart c. add the chart while keeping the destination formatting intact d. insert the chart while keeping the source formatting intact
Answers: 1
You know the right answer?
Cartesian Product Programming challenge description:
The Cartesian product of two lists of n...

Questions in other subjects: