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

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:30
Entering key dates from your course syllabi test and quiz dates, assignments due dates in your planner can you manage your schedule by allowing you to see commitments ahead of time.
Answers: 3
question
Computers and Technology, 23.06.2019 00:40
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why.a.) student.course.callnum = "csc230"; b.) cin > > student.name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student.name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist.course.credits = 3; j.) course = studenttype.course;
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
The song about casey jones a railroad engineer who gives his life on the job would most likely gall under the folk song category of? a-work song b-nonsense song c-religious song d-ballad
Answers: 1
You know the right answer?
Cartesian Product Programming challenge description:
The Cartesian product of two lists of n...
Questions
question
Biology, 27.05.2021 19:20
question
Mathematics, 27.05.2021 19:20
question
Spanish, 27.05.2021 19:20
question
History, 27.05.2021 19:20
question
Mathematics, 27.05.2021 19:20
Questions on the website: 13722360