Questions
Write a python code that calculates π using numpy rand function.

Write a python code that calculates π using numpy rand function.

In: Computer Science

The ( ) method will be called if a method is called from within a subclass...

The ( ) method will be called if a method is called from within a subclass that overrides a super class method.

In Java the (          ) keyword is used to prevent changes being made to a variable.

The property of ( ) refers to the ability of an object to take on many forms.

In Java, a character constant’s value is its integer value in the ( ) character set.

An interface requires each of the interface’s methods to be ( ) or declared abstract.

The (    ) statement forces an exception object to be generated.

Through the process of (    ) , a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.

Re-implementing an inherited method in a subclass to perform a different task from the parent class is called (    ) .

In a class definition, the special method that is called to create an instance of that class is known as a/an ( ) .

In Java, objects are passed as ( ) addresses.

List of words to choose from

Double, literal, overriding, bytecode, implemented, polymorphism, subclass, catch, protected, throws, constructor, interface, unicode, inheritance, int, overloading, memory, class, string, private, throw, main, extends, final, string literal, runtime, abstraction, prublic, jvm

In: Computer Science

Modify the bellow program by using only system calls to perform the task. These system calls...

Modify the bellow program by using only system calls to perform the task. These

system calls are open,read,write, and exit .Use text and binary files to test your programs.

#include <stdio.h>

void main(int argc,char **argv)

{

FILE *fp1, *fp2;

char ch, buf[20], *pos;

int n;

pos = buf;

if ((fp1 = fopen(argv[1],"r")) == NULL)

{

puts("File cannot be opened");

exit(1);

}

fp2 = fopen(argv[2], "w");

while ((n = fread(pos, sizeof(char), 20, fp1)) == 20)

{

fwrite(pos, sizeof(char), 20, fp2);

}

fwrite(pos, sizeof(char), n, fp2);

fclose(fp1);

fclose(fp2);

exit(0);

}

In: Computer Science

Convert the simple algebra below into Chomsky Normal Form (CNF), and then create a parse tree...

Convert the simple algebra below into Chomsky Normal Form (CNF), and then create a parse tree showing how the converted grammar could derive: x + y * z

E → E + T | T

T → T * F | F

F → (E) | x | y | z


In: Computer Science

What is an enumerated type in C? Define such a type (called chess_value) to store the...

  1. What is an enumerated type in C? Define such a type (called chess_value) to store the

    possible values of a chess piece – pawn, rook, knight, bishop, queen and king.

  2. Create a structure called struct piece to store a chess piece. This structure should have two fields, one of which is the value of the piece, and should be of the enumerated type

    defined in Q4. The second field is colour, which should be either 1 (white) or 0 (black).

  3. Define an 8x8 array of "struct piece" pointers that can be used to model a chessboard. Each element of the array is pointer to a piece structure, that is either NULL if the square is empty or points to a relevant piece structure if it isn’t. Use malloc to allocate and setup both King pieces on the board. The white king should be placed in row 1, column 5, and the black king in row 8, column 5. You should leave all other squares as NULL.

In: Computer Science

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