In the java programming language.
How would you find if numbers in an array element add up to a certain sum so for example if my array element consists of: INPUT: 200, 10, 50, 20 and my output asks if these elements add to: 210? YES (200+10) 260? YES (200+10+50) 30? NO What method would you suggest to look through the elements in an array (which im going to add through a text file) and determine if these sums exist in O(n^2)?
In: Computer Science
State whether each of the following is true or false. Justify your answer!
a. There are infinitely many finite languages.
b. Union of any two languages over alphabet {0, 1} is always regular.
c. The value of n3 +6n2 +5n is divisible by 6 for any integer n>0. Provide a proof.
d. Single state NFA can recognize only finite languages (languages with finitely many strings)
e. Intersection of any language and its complement is always regular.
In: Computer Science
Multiple choice
Consider the following ORACLE relations :
One (x, y) = {<2, 5>, <1, 6>, <1, 6>, <1,
6>, <4, 8>, <4, 8>}
Two (x, y) = {<2, 55>, <1, 1>, <4, 4>, <1,
6>, <4, 8>, <4, 8>, <9, 9>, <1, 6>}
Consider the following two SQL queries SQ1 and SQ2 :
SQ1 : SELECT * FROM One) EXCEPT (SELECT * FROM Two); SQ2 : SELECT * FROM One) EXCEPT ALL (SELECT * FROM Two);
2 and 2 respectively |
||
1 and 2 respectively |
||
1 and 1 respectively |
||
2 and 1 respectively |
In: Computer Science
5. What is the Netflix churn rate and what are the reasons behind this rate?
In: Computer Science
Design a strategy that minimizes the expected number of questions you will ask in the fol- lowing game. You have a deck of cards that consists of one one, two twos, three threes, and so on up to nine nines for a total of 45 cards. Someone draws a card from the shuffled deck and looks at its value (hiding it from you). The goal is to determine the value of the card through asking a series of questions, each of which must be answerable with “yes” or “no” (such as “Is the card a nine?”).
To answer this question, you should express your strategy as a decision tree. You may either explicitly draw the decision tree or describe its construction in sufficient detail so that I could draw it from your description.
Furthermore, briefly explain why this minimizes the expected number of questions you will ask in this game. You are not required to give a formal proof.
Hint: The first question to ask in the optimal decision tree is “Is the card one of {4, 5, 9}?” Equivalently, the question can be “Is the card one of {1, 2, 3, 6, 7, 8}?”
In: Computer Science
Why is it important to include a time/date stamp in the security incident response form?
In: Computer Science
What is a sensible approach to building and validating a predictive model
In: Computer Science
//JAVA
//basic please for learning programming 2. Thank you.
Write the Class Variables
Class Box is to have the following private data members:
Write the following Overridden Method
Class Box is to have an overridden equals() method that does the
following:
Write the Get and Get Methods
Class Box is to have standard get/set methods for each data
member
Write the following Auxiliary Method
Class Box is to have an auxiliary method getVolume( ). The method
is to have an access of public and return a value of type double.
The method is to do the following:
Write the Constructors
Class Box is to have two constructors with the following
specifications:
Class: Box
Write the class header
Write the following Overridden Method
Class Box is to have an overridden toString() method that does the
following:
displays the following information in the format presented:
Height: display height of the object
Width: display the width of the object
Length: display the length of the object
Write the following application class: BoxApp.
Class BoxApp is to do the following:
Height: the value of the height property
Width: the value of the width property
Length: the value of the length property
In: Computer Science
Convert UTF-8 to UTF-16 and Back
Write two Java programs and verify that they work.
Program 1 should:
Program 2 should do the same as program 1, except program 2 goes from UTF-16 to UTF-8
Submit:
import java.io.*;
public class WriteUTF8 {
public static void main(String[] args) {
File file = new
File("utf8_output.txt");
FileOutputStream fs= null;
try {
fs = new
FileOutputStream(file);
}
catch (FileNotFoundException fnfe)
{
System.err.println("file not found");
}
try {
fs.write("Фёдор".getBytes("UTF-8"));
fs.close();
}
catch(IOException ioe){
System.err.println("unable to write to file");
}
}
}
---
import java.io.*;
public class WriteUTF16 {
public static void main(String[] args) {
File file = new
File("utf16_output.txt");
FileOutputStream fs= null;
try {
fs = new
FileOutputStream(file);
}
catch (FileNotFoundException fnfe)
{
System.err.println("file not found");
}
try {
fs.write("Фёдор".getBytes("UTF-16"));
fs.close();
}
catch(IOException ioe){
System.err.println("unable to write to file");
}
}
}
--
In: Computer Science
1a) Write the start of the class declaration for a node in a linked list (give the name of the class and the instance variables). The name of the node should be SpecialNode. The data in each SpecialNode will include both a String and a Song object.
b)Using the SpecialNode class you created in question above, write a constructor forSpecialNode that has three parameters and initializes all the SpecialNode instance variables.
c) Write a line of code to instantiate a SpecialNode object to initialize the SpecialNodeinstance variables. Use the constructor you wrote in the previous question.
Song rockstar = new Song("Rockstar", 5);
SpecialNode sn = ___________________________________ ;
In: Computer Science
I am using NetBeans IDE Java for coding. I would like the code to be commented for a better understanding.
1. Implement a class Robot that simulates a robot wandering on an infinite plane. The robot is located at a point with integer coordinates and faces north, east, south, or west.
Supply methods:
public void turnLeft()
public void turnRight()
public void move()
public Point getLocation()
public String getDirection()
The turnLeft and turnRight methods change the direction but not the location. The move method moves the robot by one unit in the direction it is facing. The getDirection method returns a string "N", "E", "S", or "W".
In: Computer Science
1. Provide an explanation of the network detection
methods in the chapter, give an example of their importance and
discuss the issue(s) associated with each method.
In: Computer Science
Operating systems typically split functionality into layers. Explain the advantages and disadvantages of the structure of software as layers in distributed systems.
In: Computer Science
Q2) Using the program in Figure 2, identify the values of pid at
lines A, B, C, and D. (Assume that the actual pids of the parent
and child are 2600 and 2603, respectively.) Give a brief
explanation.
#include <sys/types.h> #include <sys/wait.h> #include
<stdio.h> #include <unistd.h>
int main() { pid_t pid, pid1; /*fork a child process*/
pid = fork(); if (pid < 0) { /* error occurred*/ fprintf(stderr,
"Fork Failed"); return 1; } else if (pid == 0) { /*child process*/
pid1 = getpid(); printf("child: pid = %d", pid); /* A */
printf("child: pid1 = %d", pid1); /* B */ } else { /*parent
process*/ pid1 = getpid(); printf("parent: pid = %d", pid); /* C */
printf("parent: pid1 = %d", pid1); /* D */ wait(NULL); }
return 0; }
Figure 2 - What are the pid values displayed?
In: Computer Science
Question 1
In: Computer Science