Another pitfall cited in Section 1.10 is expecting to improve the overall performance of a computer by improving only one aspect of the computer. Consider a computer running a program that requires 250 s, with 70 s spent executing FP instructions, 85 s executed L/S instructions, and 40 s spent executing branch instructions.
By how much is the total time reduced if the time for FP
operations is reduced by 20%?
By how much is the time for INT operations reduced if the
total time is reduced by 20%?
Can the total time can be reduced by 20% by reducing only
the time for branch instructions?
In: Computer Science
public class Node<T>
{
Public T Item { get; set; }
Public Node<T> Next; { get; set; }
public Node (T item, Node<T> next)
{ … }
}
public class Polynomial
{
// A reference to the first node of a singly linked list
private Node<Term> front;
// Creates the polynomial 0
public Polynomial ( )
{ }
// Inserts term t into the current polynomial in its proper
order
// If a term with the same exponent already exists then the two
terms are added together
public void AddTerm (Term t)
{ … }
// Adds polynomials p and q to yield a new polynomial
public static Polynomial operator + (Polynomial p, Polynomial
q)
{ … }
// Multiplies polynomials p and q to yield a new polynomial
public static Polynomial operator * (Polynomial p, Polynomial
q)
{ … }
// Evaluates the current polynomial at x
public double Evaluate (double x)
{ … }
// Prints the current polynomial
public void Print ( )
{ … }
}
DON'T SOLVE THE FIRST TASK JUST THE ONE AFTER THIS LINE. The first
task is their for reference
C# Please :)
In a separate namespace, the class Polynomial (Version
2) re-implements a polynomial as a linear array
of terms ordered by exponent. Each polynomial is also reduced to
simplest terms, that is, only one term
for a given exponent.
public class Polynomial
{
// P is a linear array of Terms
private Term[ ] P;
…
// Re-implement the six methods of Polynomial (including the
constructor)
…
}
In: Computer Science
1 Linear Algebra in Numpy
(1) Create a random 100-by-100 matrix M, using numpy method
"np.random.randn(100, 100)", where
each element is drawn from a random normal distribution.
(2) Calculate the mean and variance of all the elements in M;
(3) Use "for loop" to calculate the mean and variance of each row
of M.
(4) Use matrix operation instead of "for loop" to calculate the
mean of each row of M, hint: create a vector
of ones using np.ones(100, 1)?
(5) Calculate the inverse matrix M−1
(6) Verify that M−1M = MM−1 = I. Are the off-diagnoal elements
exactly 0, why?
In: Computer Science
In: Computer Science
JAVA CODE FILL IN THE BLANKS
you are to complete the skeleton program by completing
* the To Do sections. I would suggest doing this a
* little bit at a time and testing each step before you
* go on to the next step.
*
* Add whatever
code is necessary to complete this assignment
*********************************************************************/
//Add whatever code is necessary to complete this assignment
public class Methods
{
public static void main(String[] args)
{
//create two integer variables
below
//ask the user to enter numbers
into each of the variables
(
//call the max method to determine
which number is the biggest
//and then display the result to
the screen in a message that looks like...
//"The highest number you entered
was X"
//call the difference method to
determine the difference between the two numbers
//and then display the result to
the screen in a message that looks like...
//"The difference between X and Y
is Z" (where X is the first number,
//Y is the second number and Z is
the difference)
//***The difference should always
be a positive value***
}//end main
//write a max method here. It should accept two
numbers and return the highest
//of those two numbers
//write a difference method here. It should accept two
numbers and return the difference
//between the two numbers. *** The difference must
always be a positive number. ***
}//end Methods
In: Computer Science
You should use Visual Studio to write and test the program from this problem.
Write a complete program with a for loop that
In: Computer Science
–Who is the owner and group for each of the files?
–What permissions are assigned for these files?
–Are the permissions consistent with the results of activity you did before.
–Discuss the permissions in light of principle of least privilege.
2. Check the details of the log directory under /var/
–Who is the owner and group of the directory?
–What permissions are assigned for this directory?
–Discuss the permissions in light of principle of least privilege.
3. What happens to a file when the primary group of its user owner changes?
USE LINUX to answer
In: Computer Science
Write a C code program to implement the comparisons of three integer numbers, using only conditional operators (no if statements). Please ask the user to input random three integers. Then display the minimum, middle, and maximum number in one line. Also, please calculate and display the sum and the average value (save two digits after decimal point) of these three integers. Please write the comments line by line.
In: Computer Science
In: Computer Science
In your book there is a Class method called Square that draws a square either using a border or a solid. Using that class, create a Square2 class that also prompts the user for the character to be printed (i.e. such as #, $, whatever) and if the user enters a blank character it defaults to *.
You’ll need to modify the called private methods in Square to accept a character passed.
Note that for the purposes of this Lab it is okay to prompt the user from the class methods.
Sample session:
M:\Java253>java Square2Driver
Enter width of desired square: 9
Area = 81
What character should be used for printing? (i.e. *) #
Print with (b)order or (s)olid? s
#########
#########
#########
#########
#########
#########
#########
#########
#########
/***********************************************************
* SquareDriver.java
* Dean & Dean
*
* This is the driver for the Square class. ***********************************************************/
import java.util.Scanner;
public class SquareDriver
{
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
Square square;
System.out.print("Enter width of desired square: ");
square = new Square(stdIn.nextInt());
System.out.println("Area = " + square.getArea());
square.draw();
} // end main
} // end class SquareDriver
/************************************************************
* Square.java
* Dean & Dean
*
* This class manages squares.
************************************************************/
import java.util.Scanner;
public class Square
{
private int width;
//*********************************************************
public Square(int width)
{
this.width = width;
}
//*********************************************************
public int getArea()
{
return this.width * this.width;
}
//*********************************************************
public void draw()
{
Scanner stdIn = new Scanner(System.in);
System.out.print("Print with (b)order or (s)olid? ");
if (stdIn.nextLine().charAt(0) == 'b')
{
drawBorderSquare();
}
else
{
drawSolidSquare();
}
} // end draw
//*****************************************************
private void drawBorderSquare()
{
drawHorizontalLine();
drawSides();
drawHorizontalLine();
} // end drawBorderSquare
//*****************************************************
private void drawSolidSquare()
{
for (int i=0; i<this.width; i++)
{
drawHorizontalLine();
}
} // end drawSolidSquare
//*****************************************************
private void drawHorizontalLine()
{
for (int i=0; i<this.width; i++)
{
System.out.print("*");
}
System.out.println();
} // end drawHorizontalLine
//*****************************************************
private void drawSides()
{
for (int i=1; i<(this.width-1); i++)
{
System.out.print("*");
for (int j=1; j<(this.width-1); j++)
{
System.out.print(" ");
}
System.out.println("*");
}
} // end drawSides
} // end class Square
In: Computer Science
- Students must develop the code required to create a square two-dimensional array just large enough to store a given string in encrypted form using the given encryption algorithm. The character used after the end of the encrypted string is the ASCII delete key, set as final UNPRINTABLE_CHAR_VALUE. After this value is stored, the encryption process fills the remaining elements with random values
- Students must develop the code to decrypt a given square two-dimensional array and using the given encryption algorithm
- Students must develop other supporting methods as specified (below) to manage the encryption operations*
- Students will also document all classes and methods using the Javadoc commenting process; comments are not required to be exactly the same as found in the supporting document (below) but they should be semantically equivalent
- Students will upload the EncryptionClass.java file to this assignment; any other uploaded files will result in a reduction of the project grade, and in some cases, may cause a complete loss of credit
- Assignment Specification (Javadoc output for the project):
p1_package
Class EncryptionClass
FileIoToolsForEncryptionClass.java
import
java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class
EncryptionClass
{/**
* Constant for maximum input char
limit
*/
private final int MAX_INPUT_CHARS = 256;
/**
* Constant for unprintable char value used
as message end char
*/
private final int UNPRINTABLE_CHAR_VALUE = 127;
// ASCII for delete key
/**
* Constant for minus sign used in
getAnInt
*/
private final char MINUS_SIGN = '-';
/**
* Class Global FileReader variable so
methods can be used
*/
private FileReader fileIn;
/**
* Downloads encrypted data to file
* <p>
* Note: No action taken if array is
empty
* @param fileName String object holding
file name to use
*/
void downloadData( String fileName )
{FileWriter
toFile;
int rowIndex, colIndex;
if( arrSide > 0
)
{
try
{
toFile = new FileWriter( fileName );
toFile.write( "" + arrSide + "\r\n" );
for( rowIndex = 0; rowIndex < arrSide; rowIndex++ )
{
for( colIndex = 0; colIndex < arrSide; colIndex++ )
{
if( encryptedArr[ rowIndex ][ colIndex ] < 100 )
{
toFile.write( "0" );
}
toFile.write(" "+ encryptedArr[ rowIndex ][ colIndex ] + " "
);
}
toFile.write( "\r\n" );
}
toFile.flush();
toFile.close();
}
catch( IOException ioe )
{
ioe.printStackTrace();
}
}
}
/**
* gets an integer from the input
stream
*
* @param maxLength maximum length of
characters
* input to capture the integer
*
* @return integer captured from file
*/
private int getAnInt( int maxLength )
{
int inCharInt;
int index = 0;
String strBuffer =
"";
int intValue;
boolean negativeFlag =
false;
try
{
inCharInt = fileIn.read();
// clear space up to number
while( index < maxLength && !charInString(
(char)inCharInt,
"0123456789+-" ) )
{
inCharInt =
fileIn.read();
index++;
}
if( inCharInt == MINUS_SIGN )
{
negativeFlag = true;
inCharInt = fileIn.read();
}
while( charInString( (char)inCharInt, "0123456789" ) )
{
strBuffer += (char)( inCharInt );
index++;
inCharInt = fileIn.read();
}
}
catch( IOException ioe
)
{
System.out.println( "INPUT ERROR: Failure to capture character"
);
strBuffer = "";
}
intValue =
Integer.parseInt( strBuffer );
if( negativeFlag )
{
intValue *= -1;
}
return intValue;
}
/**
* Uploads data from file holding a square
array
*
* @param fileName String object holding
file name
*/
void uploadData( String fileName )
{
int rowIndex,
colIndex;
try
{
// Open FileReader
fileIn = new FileReader( fileName );
// get side length
arrSide = getAnInt( MAX_INPUT_CHARS
);
encryptedArr = new int[ arrSide ][ arrSide ];
for( rowIndex = 0; rowIndex < arrSide; rowIndex++ )
{
for( colIndex = 0; colIndex < arrSide; colIndex++ )
{
encryptedArr[ rowIndex ][ colIndex ]
= getAnInt( MAX_INPUT_CHARS );
}
}
fileIn.close();
}
// for opening
file
catch(
FileNotFoundException fnfe )
{
fnfe.printStackTrace();
}
// for closing
file
catch (IOException
ioe)
{
ioe.printStackTrace();
}
}
}
In: Computer Science
Linux
1. Give a command line (one command) for displaying the files lab1, lab2, lab3, and lab4. Can you give another command lines that do the same thing by making use of the file name similarities? What is the command line for displaying the files lab1.c, lab2.c, lab3.c, and lab4.c? (Hint: use shell metacharacters.)
2. How to determine the number of users who are logged on to Linux server system at this time? What command did you use to discover this?
3. Determine the name of the operating system that the Linux server runs. What command did you use to discover this
4. What are special files in UNIX? What are character special files and block special files? Run the ls /dev | wc -w command to find the number of special files that the linux server system has.
5. What is the inode number of the root directory on the linux server? Give the commands that you used to find the inode number.
In: Computer Science
ITT-270 IPv6 Stateful Autoconfig, Static and Default Routing, OSPF Guide
Directions:This assignment will configure IPv6. To complete this assignment, follow the guidelines provided below. At the end of this document you will find the related assignment questions; submit only the completed questions portion to your instructor. Note: At various points you will be required to obtain a screen capture; add this directly into the document following the related question.
Objectives
Guidelines
For this assignment, the network will look like this. The routers are Cisco 2911 models and the switches are Cisco 2960 models.
(Todd, 2016)
There will be no need to create any connections or devices for this assignment.
Capture the screen (screenshot 1) and place it with the related question below.
Capture the screen (screenshot 2) and place it with the related question below.
Capture the screen (screenshot 3) and place it with the related question below.
Before continuing, answer question 1 below.
Capture the screen (screenshot 4, 5 and 6) for each router and place them with the related questions below.
Capture the screen (screenshot 7) and place it with the related question below.
Capture the screen (screenshot 8) and place it with the related question below.
Before continuing, answer question 2 below.
Capture the screen (screenshot 9) and place it with the related question below.
Capture the screen (screenshot 10) and place it with the related question below.
Before continuing, answer questions 3 and 4 below.
Capture the screen (screenshot 11) and place it with the related question below.
Capture the screen (screenshot 12) and place it with the related question below.
Before continuing, answer question 5 below.
Capture the screen (screenshot 13) and place it with the related question below.
Capture the screen (screenshot 14) and place it with the related question below.
Capture the screen (screenshot 15) and place it with the related question below.
Before continuing, answer question 6 below.
Note: Now, it’s time to practice with OSPFv3. Unfortunately, because OSPF has automagic routing, the routing that was set before needs to be removed. Of course, one could just close the app and re-open it, but practice instead.
Before continuing, answer question 7 below.
Before continuing, answer question 8 below.
Finish this assignment by completing question 9 below.
ITT-270 Stateful Autoconfig, Static and Default Routing, OSPF – Questions
Complete the following questions as required by the prompts within the guidelines above.
A |
B |
C |
D |
E |
|
A |
--- |
||||
B |
--- |
||||
C |
--- |
||||
D |
--- |
||||
E |
--- |
A |
|
B |
|
C |
|
D |
|
E |
In: Computer Science
C++
Write a program that reads a line of text, changes each uppercase letter to lowercase, and places each letter both in a queue and onto a stack. The program should then verify whether the line of text is a palindrome (a set of letters or numbers that is the same whether read forward or backward). Please use a Queue Class and Stack class.
In: Computer Science
1. Copying and pasting from the Internet can be done without citing the Internet page, because everything on the Internet is common knowledge and can be used without citation. True False
2. You don’t have to use quotation marks when you quote an author as long as you cite the author’s name at the end of the paragraph. True False
3. When you summarize a block of text from another work, citing the source at the end of your paper is sufficient. True False
4. If you quote your roommate in an interview, you don’t have to cite him/her or use quotation marks. True False
5. You don't have to cite famous proverbs because they’re common knowledge. True False
6. If you borrow someone's idea and use it in a paper, you don’t have to cite it. True False
7. Using a few phrases from an article and mixing them in with your own words is not plagiarism. True False
8. Song lyrics don't have to be cited. True False
9. If you come across the phrase "to be or not to be" and use it in your paper, you have to cite it. True False
10. The date for George Washington’s birthday is common knowledge which means you don't have to cite the source in which you found it. True False
In: Computer Science