Question
Hi Please, I would like assistance with the data structure and algorithm questions, the code should be in java or c++ Thank you Important Note:
Hi Please, I would like assistance with the data structure and algorithm questions, the code should be in java or c++ Thank you
Important Note: For this assignment, you need to write a report addressing the topics and/or questions that appear throughout this document in bold italics. So you not only submit a working set of programs but also a report on your take on the specified topics and your solutions and/or ideas to address them.
In basic set theory, sets are defined as collections of unique elements. The followings are some operations and/or properties on sets:
We say that A is a subset of B, if every element of A is an element of B.
The union of A and B, is a set whose elements are the elements of A and the elements of B.
The intersection of A and B, is a set whose elements are the elements common to A and B.
You are asked to write a program that prompts the user for the size of two integer arrays, user input for the size must not exceed 50, you must validate this. We will use these arrays to represent our sets. These arrays will be randomly populated in the range that is 1 through double the size of the array. So if the array is of size 20, you will randomly populate it with values in the range 1-40 inclusive.
Following the above-mentioned rules for sets, you must avoid having duplicates while randomly populating them. This means that if a random number already exists in the set, you should skip that and generate another random number to store in the array. Does this process seem costly to you? Describe your answer. If you answered in affirmative, describe your solution to try and optimize the process of checking for duplicates. Refer to this segment in your report as Point 1.
You must define the union set of these sets/arrays. What do you pick as its size? You must also make sure that the union set does not have any duplicates. Refer to this in your report as Point 2.
You also must define the intersection of these sets. What would be the reasonable pick for the size of this set? Do we need to worry about duplicates in this set? Refer to this in your report as Point 3.
You must verify whether one of these sets is a subset of the other or not. How costly is this process? Have you been able to find a solution to possibly reduce the cost? Explain your answer. Refer to this in your report as Point 4.
Important note: In your report make sure you identify the trade-off factor of the choices you make in your program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started