3. (Exercise 3.4) Use the Marriage data from the mosaicData package a) Create a bar plot to show the frequency counts for each race b) Create a histogram to show the age distribution c) What distribution can you see for age? (Use comments to write in your R Markdown file) d) Create a time-series plot to show the delay by ceremony date (Note: you need to create a vector x<-1:98 first, and then create a new data frame with x=x and y=delay.)
In: Computer Science
24.10 Lab Ch24: MergeSortDouble
Create a class MergeSortDouble and implement a
sort(double[]) method using merge sort
algorithm.
Test will call the sort() method.
java please!
In: Computer Science
We plan to develop customer’s database that stores customer’s number (ID), first name, last name and balance. The program will support three operations: (a) reading and loading customer’s info from the text file, (b) entering new customer’s info, (c) looking up existing customer’s info using customer’s number(ID), (d) deleting the customer’s info and (e) the updated database will be stored in the text file after the program terminate.
Customer’s database is an example of a menu-driven program. When the program begins to execute, it first read the text file and upload customer’s info. Then it presents the user with a list of commands. The user can enter as many commands as desired, in any order. The a command prompts the user to enter customer’s number (ID), first name, last name and balance, which are then stored in the program’s database. The f command prompts the user to enter a customer number and then display the corresponding record on the screen. The q command saves the information in the database to the file specified by the user and terminate program.
Based on the project description, please design classes and their corresponding methods. You need describe each method and write API for each method (Leave method body blank) (Hint: you need design one driver class, one database class and one customer record class). Based on your design, please draw the UML diagram as well.
database.txt
12345 Sebastian vanDelden 123.22
11111 Sarah Smith 45.89
22222 Sue Johnson 7765.98
33333 Billy Hunts 374.99
Based on your design/code, please draw a simple but detailed UML diagram as well? (This is the question that needs to be answered!) the code isn't needed for this.
In: Computer Science
Write a SQL query that displays the number of customers from Mexico, USA, and Canada. Hint: The result of the SQL query should look like the following table: CustomerCountNorthAmerica 21
In: Computer Science
In: Computer Science
In: Computer Science
Using the Web, search for “software firewalls.” Examine the various alternatives available and compare their functionality, cost, features, and type of protection. Create a chart with weighted rankings according to your own evaluation of the features and specifications of each software package. Additionally, provide 1-2 supporting paragraphs for your chart and describe how/why you came to your decision on the firewall weighted rankings.
In: Computer Science
Codes for this R-Project please!
In this projects we will draw plots for different discrete
probability distributions that we have studied in class.
# 1. Binomial distribution.
We will plot the density function for the binomial distribution
Bin(n, p).
Note:
1) The values for this random variable are 0, 1, 2, ..., n.
2) The density plot will have a bar of height P(X=k), at the point
'k' on the x-axis.
3) In the plot include a vertical line at the expected value of
Bin(n,p).
Write a function plot_binom, that takes input values: n and p, and returns the density plot of Bin(n,p).
```{r}
# plot_binom <- function(n,p){
# x <- 0:n
# bin <- dbinom( _____ ) # input appropriate parameters
# mu_X <- ____ #input appropriate value for expected value
# plot(x, bin, type = "h", lwd = 5,
# main = paste("Binom density: n = ", n ,"and p = ", p),
# xlab = "x", ylab = "P(X=x)")
# abline(v = mu_X, col = 'red', lwd = 4)
# }
```
Fix n = 40. Compute plots for the following values of p: 0.05, 0.1,
0.4, 0.6, 0.9, 0.95.
Use the command "par(mfrow=c(3,2))" to have all the plots on the
same frame.
```{r}
# n <- 40
# prob_vals <- c(_______) #input appropriate values for
probability
# par(mfrow=c(3,2))
# for (p in prob_vals){
# plot_binom(____) #input the appropriate values
#}
```
Write at least two observations that you can note from these plots. Consider skewness and symmetry.
In: Computer Science
A file server needs to serve 20 users. Each user wants to download the same file of size 100 MB. The server can upload data at 100 Mbps and each client can download at 10 Mbps. A, Estimate the minimal total time required to fully download the file by all users. B, Peer-to-Peer architecture( Assume each user can upload at 3 Mbps) c. Redo a and b for users=200
In: Computer Science
Make a simple C++ program not complex
Following points are to be considered while making the program:
In: Computer Science
In your OWN words explain in detail the role of an operating system and list the main operating systems used on today’s computers.
In: Computer Science
In your OWN words explain in detail the benefits and the risks of using an online social network.
In: Computer Science
Question 3. Find a solution to the instance π = 2 3 1 4 5 7 6 of the Pancake Flipping problem using a greedy approach (15 points). Describe your algorithm using pseudocode. (10 points)
In: Computer Science
Array of Hope! Write code for a Java class ArrayPair with the following fields and methods: ArrayPair - arr1 [] : int - arr2 [] : int Fields - length1 : int - length2 : int + ArrayPair (int arraySize) Methods + add (int arrNumber, int value) : void + remove (int arrNumber) : void + equal () : boolean + greater () : boolean + print () : void Thus, there are two arrays of integers in the class with associated lengths (number of elements in each array).
Methods: ArrayPair: Constructor, instantiates the two arrays with the given size as a parameter. Sets the private lengths equal to zero since the arrays are initially empty. The constructor should not print or read anything.
add: Adds the given value to the right end of the array specified by the arrNumber (if equal to 1, adds to the arr1, if 2 adds to arr2, otherwise prints an error message and does not add the value). add should not print anything other than the error message when appropriate.
remove: Removes the rightmost element of the array specified by arrNumber. If the array is empty, an error message should be printed. remove should not print anything other than an error message when appropriate.
equal: Returns true if the two arrays have the same number of values and the exact same values in the same order. Otherwise, equal should return false. equal should not print anything to output.
greater: greater returns true if arr1 has more elements than arr2. greater returns false if arr2 has more elements than arr1. If the two arrays have the same number of elements, compare corresponding elements in the two arrays. For the first non-equal pair of values: if the arr1 value is greater than the arr2 value, true is returned; if the arr2 value is greater than the arr1 value, false is returned. If all the values are equal, false is returned.
print: Prints the values in both of the arrays with labels.
Main Program (Java class PairApp) Program first creates an ArrayPair object. The program then repeatedly reads commands of add, remove, equal, greater, print, or quit, until the user enters quit. If the user enters: add: Prompts the user for array number and value and calls add method to add that value to the given array. remove: Prompts the user for array number and calls the remove method to remove that element from the given array. equal: Calls equal method and prints whether or not the two arrays are equal. greater: Calls greater method prints whether or the not the first array is greater than the second. print: Calls print to print the values in the arrays. Note these further requirements: • User options should be accepted as uppercase or lowercase. • An error message is printed for an illegal choice. • The program should print an ending message when stopping. There is a sample run on the next page. Your output should follow the given text and spacing. Include a header comment describing the program and comment all variables, control structures and methods in the program.
In: Computer Science
Question 3.[10 pt]
As indicated in the course book and discussed in the class extensively, there is
generally an efficiency trade-off among execution time, memory usage and communication
overhead for a given algorithm. Please give at least two examples where such a trade-off occurs.
For example, can you give an algorithm example wherein more storage permits faster execution,
or vice versa? Similarly, can you exemplify another algorithm wherein there are trade-offs
among communication and/or memory and/or execution time?
Algorithm Trade-off Example Brief Discussion 1 [5pt]:
Write a paragraph here by explaining the
name of the algorithm and how the performance trade-off.
Algorithm Trade-off Example Brief Discussion 2 [5pt]:
Write a paragraph here by explaining the
5
name of the algorithm and how the performance trade-off occurs.
Question 4. [30 pt]
In this exercise, we start getting familiar withtwo-dimensional arrays, i.e., a
matrix (remember that matrices are nothing but 2D arrays).Matrices are one of the most
fundamental data structures, and they are used in every aspect of Information Technology
including but not limited to AI, cyber-security and software engineering. The most basic
definition of a matrix is here:
https://www.mathsisfun.com/algebra/matrix-introduction.html
Specifically, as an example was given in the above link for 2x2 matrix, you will perform the
most basic arithmetic operation on a matrix,
adding two matrices entry-wise
. Please see the link
below and read
“Entrywise Sum”.
Each corresponding cell in a matrix is added and put into 3
rd
target matrix.
https://en.wikipedia.org/wiki/Matrix_addition
Write a program named “
hw2.py
” that will add two matrices entry-wise. The matrix dimension
is fixed and 5x5 for this exercise. Your program should print an error if the dimensions of the
two matrices are different. In this case, print a message stating that the matrix dimensions does
not match. There are two matrices to be added. One is shown in “hw2-m1.txt”
5 2 0 3 4
2 4 1 1 0
3 0 5 6 1
0 2 6 0 1
4 1 1 0 0
6
The other one is shown in “hw2-m2.txt”
2 0 4 0 1
2 2 1 0 5
0 0 1 0 3
2 1 0 4 1
0 0 4 0 1
Read these two matrices from “.txt” files, and use your own codes to add them,
donot use built-
in functions
. Finally, you should print the result on the screen as
The result is:
7 2 4 3 5
4 6 2 1 5
3 0 6 6 4
2 3 6 4 2
4 1 5 0 1
In: Computer Science