Questions
Read about the Sieve of Sundaram. Implement the algorithm using function composition. Given an integer n,...

Read about the Sieve of Sundaram. Implement the algorithm using function composition.
Given an integer n, your function should generate all the odd prime numbers up to 2n+2.

sieveSundaram :: Integer -> [Integer]
sieveSundaram = ...

To give you some help, below is a function to compute the Cartesian product of two lists.
This is similar to zip, but it produces all possible pairs instead of matching up the list
elements. For example,

cartProd [1,2] ['a','b'] == [(1,'a'), (1,'b'), (2,'a'), (2,'b')]

It's written using a list comprehension, which we haven't talked about in class (but feel free
to research them).
cartProd :: [a] -> [b] -> [(a,b)]
catProd xs ys = [(x,y) | x <- xs, y <- ys]

In: Computer Science

Write a C++ program to play the dice game "Craps". Craps is one of the most...

Write a C++ program to play the dice game "Craps". Craps is one of the most popular games of chance and is played in casinos and back alleys throughout the world. The rules of the game are straightforward:

A player rolls two dice. Each die has six faces. These faces contain 1, 2, 3, 4, 5, and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the sum is 7 or 11 on the first throw, the player wins. If the sum is 2, 3, or 12 on the first throw (called "craps"), the player loses (i.e. the "house" wins). If the sum is 4, 5, 6, 8, 9, or 10 on the first throw, then the sum becomes the player's "point." To win, you must continue rolling the dice until you "make your point." The player loses by rolling a 7 before making the point.

At a minimum, your solution must contain the functions below.

  • void displayGameRules()
    • Open rules.txt file and read the rules from the file.
    • Display the rules to the screen.
    • Close the file
    • NOTE: Using Notepad, create a rules.txt file within your project folder and copy and paste the rules inside the file.
  • int rollOneDice()
    • NOTE: This function simulates rolling one dice
    • Generate random integer number from 1 to 6
    • return the random number
  • int rollTwoDice()
    • NOTE: This function simulates rolling two dice
    • Calls rollOneDice() function twice to get two random values
    • Print to the console "Sum: 6 (Die1: 4 Die2: 2)" where 4 is the value of the first dice and 2 is the value of the second dice and 6 is the sum of both dice.
    • return the sum.

Write a program that implements craps according to the above rules. Additionally:

  • When the program first begins, show the user the rules of Craps.
  • Before each initial throw of the dice, prompt the user to ask him/her to keep playing or quit. Gameplay ends when the user chooses to quit or runs out of money.
  • Your program should allow for wagering before each roll. This means that you need to prompt the user for an initial bank balance from which wagers will be added or subtracted.
    • Validate the initial bank balance entered by the user greater than zero. If the initial bank balance is not greater than zero, then inform the user and re-prompt.
  • Before each roll prompt the user for a wager. This includes rolls when the user is trying to make their point. Wagers must be less than or equal to the available bank balance.
    • The available bank balance is based on the accumulation of the previous wagers this game.
  • Once a game is lost or won, the bank balance should be adjusted.
  • Additional wagering details include:
    • Require the user to enter a non-zero wager for the first roll. Allow the user to enter a wager of 0 for subsequent “point” rolls.
    • Validate that the user’s wager is within the limits of the player's available balance. If the wager exceeds the player's available balance, then inform the user and re-prompt.

In: Computer Science

R-Studio (R Programming Language) 1. How would you create a vector `V` containing the values 0,...

R-Studio (R Programming Language)

1. How would you create a vector `V` containing the values 0, 0.25, 0.5, 0.75, and 1?
  
```{r}
#insert your code
```


2. Name the elements of `V`: first, second, middle, fourth, last. Describe two ways of naming elements in `V`

```{r}
#insert your code
```

3. Suppose you keep track of your mileage each time you fill up. At your last 6 fill-ups the mileage was
65311 65624 65908 66219 66499 66821 67145 67447. Enter these numbers into R as vector `miles`. Use the function `diff` on the data `miles`. What does it give? Use `sum` on the computed differences to find the total travelled distance.

```{r}
#insert your code
```

In: Computer Science

Argue analytically that a completely impure node yields the highest Gini Impurity.

Argue analytically that a completely impure node yields the highest Gini Impurity.

In: Computer Science

6)True/False with explanations: a.In KNN, the complexity of the model space can be tuned to account...

6)True/False with explanations:
a.In KNN, the complexity of the model space can be tuned to account for more complex decision boundaries by decreasing K.
b.If Margin(Model 1)>Margin(Model 2) on the same data, Model 1 will perform better on unseen data.
c.Perceptron minimizes training error when the data is linearly separable.

In: Computer Science

Assume thatthe table EMP hasthe following data EmpNo Surname Firstname 1 Smith Fred 2 Jay Emma...

Assume thatthe table EMP hasthe following data EmpNo Surname Firstname 1 Smith Fred 2 Jay Emma 2 Phelps Mark Consider the following statement: SELECT Firstname || ' ' || Surname FROM Employee What is displayed?

In: Computer Science

Docker containers can be considered a new era of virtualization that has fundamentally changed the IT...

Docker containers can be considered a new era of virtualization that has fundamentally changed the IT industry. For this discussion question, provide a brief response that describes a Docker container and how a container differs from a hypervisor.

In: Computer Science

Remarks: In all algorithm, always explain how and why they work. If not by a proof,...

Remarks: In all algorithm, always explain how and why they work. If not by a proof, at least by a clear explanation. ALWAYS, analyze the running time complexity of your algorithms. In all algorithms, always try to get the fastest possible. A correct algorithm with slow running time may not get full credit. Do not write a program. Write pseudo codes or explain in words

Question 4: Recall the problem in which you have k sorted array each of size n, which need to make one single sorted array. Find another fast way to unite the arrays that does not use Priority Queue.

In: Computer Science

Remarks: In all algorithm, always explain how and why they work. If not by a proof,...

Remarks: In all algorithm, always explain how and why they work. If not by a proof, at least by a clear explanation. ALWAYS, analyze the running time complexity of your algorithms. In all algorithms, always try to get the fastest possible. A correct algorithm with slow running time may not get full credit. Do not write a program. Write pseudo codes or explain in words

Question 5: Five an efficient data structure supporting the following operations. Insert(S, x), Delete−M ax(S), and Delete−1000 th(S) which deletes from H the 100 largest element in the structure. Assume that the number of elements is more than 100. Also assume that the numbers are pairwise distinct and so the 100”th largest element is well defined.

In: Computer Science

Write a response to the following in a minimum of 175 words. What is virtualization and...

Write a response to the following in a minimum of 175 words.

What is virtualization and its benefits?
Why has virtualization become almost necessary in today's business environment? Other than the cost of hardware and the lack of effort required to virtualize software, why businesses might decide to use virtualization?

In: Computer Science

Compare and Contrast peer-to-peer, client/server, and directory services networks. Be sure to specify the advantages and...

Compare and Contrast peer-to-peer, client/server, and directory services networks. Be sure to specify the advantages and disadvantages along with how security is managed of each type of network. PLEASE DO NOT HAND WRITE THE ANSWER!! PLEASE ANSER THE QUESTION THOROUGHLY!! IF YOU CANNOT PROVIDE 1,000 WORDS DO NOT ANSWER THE QUESTION!!

In: Computer Science

Length: 1300 words Task Answer the following essay question: "All technological change is a Faustian bargain....

Length: 1300 words

Task

Answer the following essay question:

"All technological change is a Faustian bargain. For every advantage a new technology offers, there is always a corresponding disadvantage"

Is this statement valid? Discuss Postman's observation in the context of educational technology in contemporary Australian higher education.

Postman, N. (1995). The end of education: Redefining the value of school. New York: Alfred A. Knopf.

Overview and Advice

'Higher education' in this question refers to post-compulsory education. While some research may be relevant to K-12, the focus of your discussion should be further education including University, TAFE and trade training, as this raises different issues around motivation, goals and outcomes. Remember that we are interested in evidence-based practice, so statements about participation, attitudes, behaviour and outcomes should be supported with peer-reviewed research and demographic data.

Careful question analysis is important when approaching this essay. What does discuss mean? This topic is potentially broad, so you will need to plan carefully to ensure that your argument is clearly defined and follows a logical progression. Question your own assumptions, and those of the authors you are reading; look for opportunities to demonstrate critical thinking. Use good essay and paragraph structure, and demonstrate your understanding of referencing by supporting your argument with a wide selection of carefully chosen sources.

Important: We are interested in investigating the pros and cons of technology in education; this essay is not about Postman’s broader views, or his work; only the statement presented in the question (which should be mentioned in your introduction).

In: Computer Science

R.R.Word.file.R.R (Main Focus of Cheg-Study!) // this is the question below You will create specific customer...

R.R.Word.file.R.R

(Main Focus of Cheg-Study!)

// this is the question below

You will create specific customer classes with specialized behaviors for a regular subscription and platinum

subscription. This will focus on the concepts of inheritance and polymorphism.

Main objective. This will consist of four classes: Customer, RegularCustomer, PlatinumCustomer, and

Tester (or any name you’d prefer for the main method file). The Customer class will have a

name and type. The RegularCustomer and PlatinumCustomer classes will inherit both of these

fields from the Customer class. The PlatinumCustomer class will also have a discount field. The

methods for each of these classes will be the following:

Customer

* Customer (constructor)

* setName

* setType

* getName

* getType

* toString

RegularCustomer:

* RegularCustomer (constructor)

* toString

PlatinumCustomer

* PlatinumCustomer (constructor)

* setDiscount

* getDiscount

* toString

For the RegularCustomer and PlatinumCustomer constructors, the type of subscription should

be set to “regular” or “platinum". Each of these two constructors should also take

advantage of inheritance when setting the fields. Given a name of “David” and a type of

“regular”, the toString method for Customer and RegularCustomer should print the following:

David has a regular subscription.

The toString method for PlatinumCustomer should also include the discount. Assume a discount

of 7% for the following:

David has a platinum subscription. The current discount on purchases for this subscription is

7.0%.

In the Tester class, make a main method where you create a Customer reference variable. Ask

the user to input a type. If the user enters “regular” for the type, ask for the name and construct

a RegularCustomer object. If the user enters “platinum” for the type, ask for the name and a

discount and then construct a PlatinumCustomer object. Finally, print this created object

to the console.

Take note of one issue with this design. RegularCustomer and

PlatinumCustomer both inherit setType from Customer, but the user should never be able to

change the type for either of these subclasses. Implement an overriding setType for each of

these two subclasses that prevents the type from being changed.

The workflow of the main method should be similar to the following:

For a Regular Subscription;

run:

Please enter a type: regular

Please enter a name: David

David has a regular subscription.

Build successful (total time: 6 seconds)

For a Platinum Subscription;

Please enter a type: platinum

Please enter a name: David

Please enter a discount: 7

David has a platinum subscription.

The current discount on purchases for this subscription is 7.0%

Build successful (total time: 6 seconds)

(End of Work Cheg-Study!)

In: Computer Science

1) If c is type char and i type int, what is assigned to c and...

1) If c is type char and i type int, what is assigned to c and i?
    Give answers in hex. Assume c is one byte, and i is four 
    bytes. Explain.

    c = 240;
    i = c;

2) If c is type unsigned char and i type int, what is assigned to 
    c and i? Give answers in hex. Explain

    c = 240;
    i = c;

3) If c is type signed char and i type int, what is assigned to 
    c and i? Give answers in hex. Explain

    c = 240;
    i = c;
     

In: Computer Science

Exercise 4: Perform the following on the Account class and test it in the AccountArrayTest: ...

Exercise 4: Perform the following on the Account class and test it in the AccountArrayTest:  In the AccountArrayTest class, add a static method called getAverageBalance (Account accounts[]) that returns the average balance of all accounts. Use the enhanced for loop.  In the main method get and print the average accounts balance.  Add an instance method called deposit() that takes a double amount as parameter and if it is positive it adds it to the current balance. If the amount is less than or equal to zero it does nothing.  Add a static method called addInterest(Account accounts[]) that calculates the interest for each account in the accounts array (based on the interestRate value), and then deposits it into the relevant account in that array. (Hint: interest = interestRate * balance/100).  Use the above methods to apply the addInterest() for all the accounts in your AccountArrayTest. Print the accountNo and balance after the update.

In: Computer Science