left ALL O 1. Question 1 There are two arrays, a and b, each of size...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
left ALL O 1. Question 1 There are two arrays, a and b, each of size n. Assuming 1-based indexing, let Xora(i, j) denote the xor of values of the subarray a[,...]]. Similarly, define Xorb(i, j) for array b as the xor of the values of the subarray b[i.. Find the sum of Xora(i, j)^Xorb(i, j) over all possible pairs (i j) such that (1 sisjsn). 2 Note: '' is the xor operator. Example Given n = 3, a = [1, 3, 5] and b = [1, 2, 3]. Xora (1, 1)^ Xorb (1,1) = 1^1 = 0. Xora (2, 2) ^ Xorb (2,2) = 3^2 = 1. 9 Xora (3, 3) ^ Xorb (3,3)=5^3 = 6. Xora (1, 2) ^ Xorb (1,2) = (1^3) ^ (1^2) = 2^3 = 1. Xora (2, 3) ^ Xorb (2,3) = (3^5) ^ (2^3) = 6^1 = 7. Xora (1, 3)^ Xorb (1,3) = (1^3^5)^ (1^2^3) = 7^0 = 7. The answer is the sum of the xor values, 0+1+6+1+7+7 = 22. Function Description Complete the function calculateAnswer in the editor below. ALL There are two arrays, a and b, each of size n. Assuming 1-based indexing, let Xora(i, j) denote the xor of values of the subarray a[i,...., j]. Similarly, define Xorb(i, j) for array bas the xor of the values of the subarray b[i,.... j]. Find the sum of Xora(i, j)^Xorb(i, j) over all possible pairs (i, j) such that (1 is jn). E 2 3 Note: '' is the xor operator. Example Given n = 3, a = [1, 3, 5] and b = [1, 2, 3]. Xora (1, 1)^ Xorb (1,1) = 1^1 = 0. Xora (2, 2) ^ Xorb (2,2) = 3^2 = 1. Xora (3, 3) ^ Xorb (3,3) = 5^3 = 6. ALL 1 2 3 22. Function Description Complete the function calculateAnswer in the editor below. calculateAnswer has the following parameter(s): int a[n]: an array of integers int b[n]: an array of integers Returns long the sum of the xor values as described Constraints 1 n 2*105 0 < a[i], b[i] < 108 3 2 Sample Case 0 Sample Input For Custom Testing 17 18 19 STDIN FUNCTION 20 21 223212 a[] size n = 2 22 a = [2, 3] 23 b[] size n = 2 b= [1,2] Sample Output 6 Explanation Xora (1, 1)^ Xorb (1, 1) + Xora (2, 2) ^ Xorb (2, 2) + Xora (1, 2)^ Xorb (1,2) = 2^1+3^2+ ((2^3)^(1^2)) = 3+1+(1^3) = 3+1+2=6 Sample Case 1 Sample Input For Custom Testing STDIN 1 1 1 Sample Output 1 FUNCTION a[] size n = 1 a = [0] b[] size n = 1 b = [1] Explanation Xora (1, 1)^ Xorb (1, 1) = 0^1 = 1 10 /* 111 9012 11 * 12 13 345 * Complete the 'calculateAnswer' function below. * The function is expected to return a LONG_INTEGER. The function accepts following parameters: 14 15 * 1. 16 17 67 18 * */ INTEGER_ARRAY a 2. INTEGER_ARRAY b long calculate Answer (vector a, vector b) { 19 20 21 } 22 23 int main() left ALL O 1. Question 1 There are two arrays, a and b, each of size n. Assuming 1-based indexing, let Xora(i, j) denote the xor of values of the subarray a[,...]]. Similarly, define Xorb(i, j) for array b as the xor of the values of the subarray b[i.. Find the sum of Xora(i, j)^Xorb(i, j) over all possible pairs (i j) such that (1 sisjsn). 2 Note: '' is the xor operator. Example Given n = 3, a = [1, 3, 5] and b = [1, 2, 3]. Xora (1, 1)^ Xorb (1,1) = 1^1 = 0. Xora (2, 2) ^ Xorb (2,2) = 3^2 = 1. 9 Xora (3, 3) ^ Xorb (3,3)=5^3 = 6. Xora (1, 2) ^ Xorb (1,2) = (1^3) ^ (1^2) = 2^3 = 1. Xora (2, 3) ^ Xorb (2,3) = (3^5) ^ (2^3) = 6^1 = 7. Xora (1, 3)^ Xorb (1,3) = (1^3^5)^ (1^2^3) = 7^0 = 7. The answer is the sum of the xor values, 0+1+6+1+7+7 = 22. Function Description Complete the function calculateAnswer in the editor below. ALL There are two arrays, a and b, each of size n. Assuming 1-based indexing, let Xora(i, j) denote the xor of values of the subarray a[i,...., j]. Similarly, define Xorb(i, j) for array bas the xor of the values of the subarray b[i,.... j]. Find the sum of Xora(i, j)^Xorb(i, j) over all possible pairs (i, j) such that (1 is jn). E 2 3 Note: '' is the xor operator. Example Given n = 3, a = [1, 3, 5] and b = [1, 2, 3]. Xora (1, 1)^ Xorb (1,1) = 1^1 = 0. Xora (2, 2) ^ Xorb (2,2) = 3^2 = 1. Xora (3, 3) ^ Xorb (3,3) = 5^3 = 6. ALL 1 2 3 22. Function Description Complete the function calculateAnswer in the editor below. calculateAnswer has the following parameter(s): int a[n]: an array of integers int b[n]: an array of integers Returns long the sum of the xor values as described Constraints 1 n 2*105 0 < a[i], b[i] < 108 3 2 Sample Case 0 Sample Input For Custom Testing 17 18 19 STDIN FUNCTION 20 21 223212 a[] size n = 2 22 a = [2, 3] 23 b[] size n = 2 b= [1,2] Sample Output 6 Explanation Xora (1, 1)^ Xorb (1, 1) + Xora (2, 2) ^ Xorb (2, 2) + Xora (1, 2)^ Xorb (1,2) = 2^1+3^2+ ((2^3)^(1^2)) = 3+1+(1^3) = 3+1+2=6 Sample Case 1 Sample Input For Custom Testing STDIN 1 1 1 Sample Output 1 FUNCTION a[] size n = 1 a = [0] b[] size n = 1 b = [1] Explanation Xora (1, 1)^ Xorb (1, 1) = 0^1 = 1 10 /* 111 9012 11 * 12 13 345 * Complete the 'calculateAnswer' function below. * The function is expected to return a LONG_INTEGER. The function accepts following parameters: 14 15 * 1. 16 17 67 18 * */ INTEGER_ARRAY a 2. INTEGER_ARRAY b long calculate Answer (vector a, vector b) { 19 20 21 } 22 23 int main()
Expert Answer:
Related Book For
Probability And Statistics
ISBN: 9780321500465
4th Edition
Authors: Morris H. DeGroot, Mark J. Schervish
Posted Date:
Students also viewed these programming questions
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Prepare the schedule of year-end deferred tax assets and liabilities for each year. The schedule should separately list the sources of the firms ending deferred tax assets and deferred tax...
-
Use the following equation to derive a demand schedule and a demand curve. What types of products might exhibit this type of nonlinear demand curve? Explain. Q = 100P-0.3
-
What is a liquidated damages clause?
-
1. Identify 3 students to play the roles of the employees. Ask these 3 individuals to read their roles below. 2. Identify 1 student to play the role of the president of the social enterprise (Taylor...
-
Dyer and Salinas have decided to form a partnership. They have agreed that Dyer is to invest $120,000 and that Salinas is to invest $40,000. Dyer is to devote one-half time to the business and...
-
Explain the advantages of the relational model. Conduct some light research on the Web and describe how it differs from other data models. Explain some alternatives to the relational model. Please...
-
Given figure shows an arrangement of six fixed charged particles. The net electrostatic force F acting on charge + q at the origin O due to other charges is :- (1) (3) A +q (4) 14 (2) zero -94 2a 6q...
-
The balance sheet, Income statement and statement of change in equity have been required statements for years, for investors and stakeholders to establish going concern, probability and growth but...
-
The objective of this portion of the assignment is to help you develop your financial planning skills by creating two SMART financial goals. Using the SMART Goal Guidelines, create TWO SMART goals....
-
Pierre works at Winners and as an employee he is given the ability to buy a suit for $100 when regular customers would pay $500 for the same suit. Winners cost for the suit is $150. Does Pierre have...
-
A tax planning activity for February would be to check to see if you have received all of your W-2 forms (salary and wages) and all of your forms (interest and dividends) so you can begin to organize...
-
1. What are the basic differences between insurance premiums and taxes as sources of medical care financing? 2. Why is obesity such a problem in so many countries worldwide? 3. Why is it so difficult...
-
Which of the following could be used as a basis to allocate profits among partners who are active in the management of the partnership? 1) Allocation of salaries. 2) The number of years with the...
-
Write each fraction as a percent. 7 50
-
On September 29, 2008, the stock market fell almost 7%. How can we reconcile these kinds of huge losses in the stock market with the efficient market hypothesis?
-
In 2018, Germany had the worlds largest current account surplus of US$291 billion. Using this one piece of information, answer the following questions. a. Which was greater, the income Germans earned...
-
In the first quarter of 2019, the output gap in the United States was 0.8%. Make a prediction about what you think the output gap will be in the second quarter of 2019. Explain your reasoning.
Study smarter with the SolutionInn App