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 13:30
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
question
Computers and Technology, 23.06.2019 01:50
Write a program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations: a. double the number. b. reverse the digits of the number. c. raise the number to the power of 2, 3, or 4. d. sum the digits of the number. e. if the number is a two-digit number, then raise the first digit to the power of the second digit. f. if the number is a three-digit number and the last digit is less than or equal to 4, then raise the first two digits to the power of the last digit. after performing an operation if the number is less than 10, add 10 to the number. also, after each operation determine if the number is prime. each successive operation should be performed on the number generated by the last operation. your program should not contain any global variables and each of these operations must be implemented by a separate function. also, your program should be menu driven. 7. (fraction calculator) write a program that
Answers: 1
question
Computers and Technology, 23.06.2019 18:20
What is wi-fi infrastructure? a metropolitan area network that uses radio signals to transmit and receive data a communications technology aimed at providing high-speed wireless data over metropolitan area networks a means by which portable devices can connect wirelessly to a local area network, using access points that send and receive data via radio waves includes the inner workings of a wi-fi service or utility, including the signal transmitters, towers, or poles and additional equipment required to send out a wi-fi signal
Answers: 2
question
Computers and Technology, 23.06.2019 22:40
22. sata3 allows for data transfer rates of 600 mb/s. explain why you would likely not be able to copy data from one hard drive to another at anywhere close to this speed. also, what could be upgraded on the computer to achieve transfer speeds closer to 600 mb/s
Answers: 1
You know the right answer?
Cartesian Product Programming challenge description:
The Cartesian product of two lists of n...
Questions
question
Mathematics, 23.10.2020 04:01
question
Biology, 23.10.2020 04:01
question
Mathematics, 23.10.2020 04:01
question
Mathematics, 23.10.2020 04:01
question
Mathematics, 23.10.2020 04:01
question
Mathematics, 23.10.2020 04:01