subject

Consider the following problem: Input: Two sorted arrays, A, B. A and B together contain n integers. Output: The union and the intersection of A and B. For example, if A and B are: {0, 0, 0, 1, 2, 3, 97, 98} {0, 1, 2, 3, 4, 4, 10, 98, 100, 100} The union of A and B should be {0, 1, 2, 3, 4, 10, 97, 98, 100}. The intersection of A and B should be {0, 1, 2, 3, 98}. There should be NO duplicates in the union and intersection. Give an in-place algorithm that solves this problem in O(n) time. (i) describe the idea behind your algorithm in English (ii) Complete the method of union() and intersection(); (iii) analyze its running time. Regarding requirement (iii): Unless otherwise specified, show the steps of your analysis and present your result using big-o. public class Problemi { public static void intersection(int[] si, int[] s2) { // complete the intersection() method to output // elements that occur in both si and s2 // feel free to change method type and parameters // Full credit will awarded to algorithms O(n) and in-place } { public static void union(int[] si, int[] s2) // complete the union() method to output // the union s1 and s2 // feel free to change method type and parameters // Full credit will awarded to algorithms O(n) and in-place } public static void main(String[] args) { // TODO Auto-generated method stub // Test your intersection() method here int[] testarray1 = {0, 0, 0, 1, 2, 3, 97, 98}; int[] testarray2 = {0, 1, 2, 3, 4, 4, 10, 98, 100, 100); System. out. println("intersection of testarray1 and testarray2: "); intersection(testarray1, testarray2); //should output 0, 1, 2, 3, 98 System. out. println("union of testarray1 and testarray2: "); union(testarrayı, testarray2); // should output 0, 1, 2, 3, 4, 10, 97, 98, 100 } }

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:30
What elements related to the release and success of the nes console do you see in modern console releases? what elements are no longer relevant to modern console gaming?
Answers: 3
question
Computers and Technology, 23.06.2019 07:00
1. you have a small business that is divided into 3 departments: accounting, sales, and administration. these departments have the following number of devices (computers, printers, etc.): accounting-31, sales-28, and administration-13. using a class c private network, subnet the network so that each department will have their own subnet. you must show/explain how you arrived at your conclusion and also show the following: all available device addresses for each department, the broadcast address for each department, and the network address for each department. also, determine how many "wasted" (not usable) addresses resulted from your subnetting (enumerate them).
Answers: 3
question
Computers and Technology, 23.06.2019 11:00
How should you specify box sizes on a web page if you want the boxes to vary according to the font size of the text they contain? a. in pixels b. in inches c. as percentages d. in em units
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
You know the right answer?
Consider the following problem: Input: Two sorted arrays, A, B. A and B together contain n integers....
Questions
question
Health, 27.10.2020 05:40
question
Mathematics, 27.10.2020 05:40
Questions on the website: 13722362