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, 23.06.2019 01:40
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut off on an hev are both colored orange
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Jamie has to enter the names, employee id’s, and income of a group of employees into a worksheet. which option will jamie use to describe the data
Answers: 3
question
Computers and Technology, 24.06.2019 11:00
These statements describe lists in presentation programs: a. bullets can be turned off and on. b. bullets cannot be turned off. c. bullet styles, colors, and sizes can be changed. d. lists don't have to use bullets or numbers. e. numbering styles, colors, and sizes can be changed. f. numbers can be turned off and on. g. numbers cannot be turned off. select all that apply
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
Mathematics, 27.10.2020 21:20
question
Mathematics, 27.10.2020 21:20
question
Mathematics, 27.10.2020 21:20
question
Mathematics, 27.10.2020 21:20
Questions on the website: 13722361