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, 22.06.2019 22:30
You are new to microsoft certification and want to start out by getting a certification geared around windows 8. what microsoft certification should you pursue?
Answers: 1
question
Computers and Technology, 22.06.2019 23:00
Suppose s, t, and w are strings that have already been created inside main. write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. that is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. if these conditions hold your code should print (the boolean value) true. if not, your code should print false. (strictly means: no ties) example: if s, t, and w are "cat", "hats", and "skies" your code should print true - their lengths are 3-4-5; but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5 enter your code in the box below
Answers: 2
question
Computers and Technology, 24.06.2019 06:30
Ineed to know the anwser to all these questions
Answers: 2
question
Computers and Technology, 25.06.2019 09:20
Part d: float check string has a method s.isdigit() that returns true if string s contains only digits and false otherwise, i.e. s is a string that represents an integer. write a function named float_check that takes one parameter that is a string and returns true if the string represents a float and false otherwise. for the purpose of this function we define a float to be a string of digits that has at most one decimal point. note that under this definition an integer argument will return true. remember “edge cases” such as “45.” or “.45”; both should return true. for example: float_check('1234') returns true float_check('123.45') returns true float_check('123.45.67') returns false float_check('34e46') returns false float_check('.45') returns true float_check('45.') returns true float_check('45..') returns false
Answers: 2
You know the right answer?
Cartesian Product Programming challenge description:
The Cartesian product of two lists of n...
Questions
question
Mathematics, 06.01.2020 06:31
question
Mathematics, 06.01.2020 06:31
question
Mathematics, 06.01.2020 06:31
Questions on the website: 13722363