Question:
Consider the following C language instruction.
A[10] = ((f+g) – (h+A[5])) + 100;
Translate the above code into MIPS assembly language code. Assume variables f, g, and h are associated
with registers $S0, $S1, and $S2 respectively. The base address of A is associated with register $S5.
In: Computer Science
Describe the concept of flow control and briefly describe the mechanism/s implemented by the TCP protocol for this purpose.
In: Computer Science
Write two pages about the firewall, two pages about cybersecurity, and two pages about information security systems.
In: Computer Science
when performing a reverse engineering, which of the following file types would be most easily decompiled into source code?
A so
B exe
C jar
D a
A cybersecurity analyst is securing a server that will host an e-commerce web application. Which of the following factor would prevent the financial data from being transferred in clear text? (select two)
In: Computer Science
Please finish this code and make it work. This is my homework and my professor wont allow me to change the code in main, it's a set of huge numbers need to sort by radixsort with bit operation.
#include <iostream>
using namespace std;
void radixLSD_help(int *items, int length, int bit)
{
// – Count number of items for each bucket.
// – Figure out where each bucket should be stored (positions
// of the first and last element of the bucket in the scratch
// array).
// – Copy each item to the corresponding bucket (in the scratch
// array).
// – Copy the scratch array back into items.
}
void radixLSD(int *items, int length)
{
int bit_per_item = sizeof(int) * 8;
int bit;
for (bit = 0; bit < bit_per_item; bit++)
{
radixLSD_help(items, length, bit);
cout << "Done with bit " << bit;
}
}
void sort(int *A,int n)
{
radixLSD(A, n);
}
void sort( int *A, int n);
int main()
{
int i, offset, j;
int B[10000000];
time_t t;
srand( (unsigned) time( &t ));
offset = rand()%10000000;
for( i = 0; i< 10000000; i++ )
{
B[i] = ((91*i)%10000000) + offset;
}
printf("Prepared array of 10 million integers; calling sort\n");
sort( B[], 10000000 );
printf("finished sort, now check result\n");
for( i=0, j=0; i < 10000000; i++ )
if( B[i] != i+ offset ) j++;
if( j == 0 )
printf("Passed Test\n");
else
printf("Failed Test. %d numbers wrong.\n", j );
}
In: Computer Science
PostFixEvaluator.java
import java.util.Stack;
import java.util.Scanner;
/**
* Represents an integer evaluator of postfix expressions.
Assumes
* the operands are constants.
*
* @author Java Foundations
* @version 4.0
*/
public class PostfixEvaluator
{
private final static char ADD = '+';
private final static char SUBTRACT = '-';
private final static char MULTIPLY = '*';
private final static char DIVIDE = '/';
private Stack stack;
/**
* Sets up this evaluator by creating a new
stack.
*/
public PostfixEvaluator()
{
// complete this method
}
/**
* Evaluates the specified postfix expression. If an
operand is
* encountered, it is pushed onto the stack. If an
operator is
* encountered, two operands are popped, the operation
is
* evaluated, and the result is pushed onto the
stack.
* @param expr string representation of a postfix
expression
* @return value of the given expression
*/
public int evaluate(String expr)
{
// Step 3- complete this method
}
/**
* Determines if the specified token is an
operator.
* @param token the token to be evaluated
* @return true if token is operator
*/
private boolean isOperator(String token)
{
// Step 1 - complete this
method
}
/**
* Performs integer evaluation on a single expression
consisting of
* the specified operator and operands.
* @param operation operation to be performed
* @param op1 the first operand
* @param op2 the second operand
* @return value of the expression
*/
private int evaluateSingleOperator(char operation, int
op1, int op2)
{
// Step 2 - complete this method
}
}
PostFixTester.java
import java.util.Scanner;
/**
* Demonstrates the use of a stack to evaluate postfix
expressions.
*
* @author Java Foundations
* @version 4.0
*/
public class PostfixTester
{
/**
* Reads and evaluates multiple postfix
expressions.
*/
public static void main(String[] args)
{
String expression, again;
int result;
Scanner in = new Scanner(System.in);
do
{
PostfixEvaluator
evaluator = new PostfixEvaluator();
System.out.println("Enter a valid post-fix expression one token "
+
"at a time with a space
between each token (e.g. 5 4 + 3 2 1 - + *)");
System.out.println("Each token must be an integer or an operator
(+,-,*,/)");
expression =
in.nextLine();
result =
evaluator.evaluate(expression);
System.out.println();
System.out.println("That expression equals " + result);
System.out.print("Evaluate another expression [Y/N]? ");
again =
in.nextLine();
System.out.println();
}
while
(again.equalsIgnoreCase("y"));
}
}
Could you help, please?
In: Computer Science
PLEASE USE ARRAYS IN JAVA TO ANSWER THIS
Write a 'main' method that examines its command-line arguments and
add should add the 2 numbers and print out the result.
subtract should subtract the 2 numbers and print out the
results.
Double should add the number to itself and then output the
result.
Command line arguments + 5 2 : should print 7
Command line arguments - 5 2 : should print 3
Command line arguments & 5 : should print 10
In: Computer Science
Please describe trackers in terms of inference control. Please give two methods to mitigate trackers.
In: Computer Science
Q: Using Python: Am trying to write a code that can be tested. Any assistance will be appreciated.
Would want Help in understanding and solving this example from Data Structure & Algorithms (Computer Science) with the steps of the solution to better understand, thanks.
The purpose of this assignment is the application of
queues.
A prime number is a positive integer other than 1 and is divisible
only by 1 and itself. For example, 7 is a prime number because the
only positive factors of 7 are 1 and 7. On the other hand, 12 is
not a prime number because 2, 3, 4, and 6 are also factors of
12.
You are asked to write a function to compute the prime numbers up
to a given value. The function is named sieve and it will take an
integer n as parameter. The function should return a list that
contains all prime numbers up to (and including, if appropriate) n,
the numbers in the returned list must be in ascending order.
def sieve (n):
For example:
• sieve (10) ➔ [2, 3, 5, 7]
• sieve (11) ➔ [2, 3, 5, 7, 11]
• sieve (20) ➔ [2, 3, 5, 7, 11, 13, 17, 19]
• sieve (100) ➔ [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
The approach we will use is called the Eratosthenes sieve, which is
discovered 2,300 years ago by Eratosthenes. We will explain the
process in modern language and use a queue data structure in the
process.
We start by creating an empty queue and enqueue all the numbers
from 2 to n (inclusively, and in ascending order) into the
queue.
During each round, the first number k at the front of the queue is
a prime number; dequeue and append it to the result. Then we go
through each number in the queue and delete the
numbers that are divisible by k. The easiest way to do this is
first dequeue a number from the queue, if the number is divisible
by k, do nothing (that is, we discard the number), otherwise,
enqueue it back to the queue (and keep it). (Note that you may have
to keep track the number of dequeues you have to do.)
The process finishes when the queue becomes empty.
Examples:
>>> runTestCase (50) Test 50 failed - expecting a list of length 630, got one of length 1 instead.
from ArrayQueue import ArrayQueue
def sieve (n): return [1]
In: Computer Science
For input you can either a console Scanner or a dialog box (a modal dialog) and the static method showInputDialog() of the JOptionPane class which is within the javax.swing package like this String name= newJOptionPane.showInputDialog(” Please enter your data:”). Then convert the String object to a number using Integer.parseInt() or Double.parseDouble()
---
Write a java ”Statistics program” to calculate the mean, variance and standard deviation for a given set of numbers. The user in entering the data interactively. The size of the data set will be determined at run time. Test it with all methods taught in chapter 8 (user input, random, loop, redirection). Recall the following formulas for mean, variance, and Standard deviation.
In: Computer Science
Regarding BYOD, for an organization that does not yet offer it, what are the various steps and phases to consider during implementation? (You can not use the book as a resource)
Your sources of information must be cited within the content of your answer and the references listed after your signature, following the APA style. Only peer-reviewed references are acceptable.
In: Computer Science
Given:
class Monster
{
private:
string name;
int dangerLevel;
public:
Monster(sting, int);
virtual void hunt() = 0;
virtual void fight(Monster&);
string getName() const;
};
class GiantMonster : public Monster
{
protected:
int height;
public:
GiantMonster(string, int, int);
virtual void trample();
};
class Dinosaur : public GiantMonster
{
public:
Dinosaur(string, int, int);
void hunt();
void roar();
};
class Kraken : protected GiantMonster
{
public:
Kraken(string, int, int);
virtual void hunt();
void sinkShip();
};
Indicate if the code snippets below are valid or invalid:
a)
GiantMonster * m = new Kraken (“Sea Horror”, 500, 100);
b)
Kraken * k = new Kraken(“Cthulu”, 500, 100);
Cout << k->getName() << endl;
c)
Dinosaur trex(“T-Rex”, 100, 70);
GiantMonster m = trex;
m.roar();
d)
Monster * m = new GiantMonster (“Godzilla”, 100, 300);
e)
Dinosaur dino ( “Triceratops”, 0, 150);
Dinosaur trex ( “T-rex”, 200, 120);
Trex.fight(dino);
f)
Dinosaur * d = new Dinosaur (“T-Rex”, 100, 50);
GiantMonster * g = new Dinosaur (“Godzilla”, 100, 500);
g->fight(*d);
g)
Dinosaur * d = newGiantMonster(“T-Rex”, 100, 50);
In: Computer Science
One day Tom found a weird-looking computer in his basement. After studying it, Tom figured out that this computer stores floating point numbers in a way similar to the IEEE 754 standard. However, it uses 26 bits. Among these bits, the most significant (i.e. the leftmost) bit is for the sign (same as IEEE 754), the following 6 bits are for the biased exponent with the bias as 31, and the rest are for the significand. If the real number -0.84375 is stored on the computer, what are the 26 bits stored? Show the result in the order of sign, biased exponent and significand. Separate them by comma.
In: Computer Science
Use this constant dictionary as a global variable:
tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 }
Implement function scrabblePoints(word) that returns the calculated points for the word based on the tile_dict above. The word parameter is a string. This function takes the string and evaluates the points based on each letter in the word (points per letter is set by the global dictionary). P or p is worth the same points. No points calculated for anything that is not A-Z or a-z.
[You may use upper() and isalpha() ONLY and no other method or built-in function]
Examples:
word = “PYTHON”
print(scrabblePoints(word))
returns:
14
word = “hello!!”
print(scrabblePoints(word))
returns:
8
word = “@#$=!!”
print(scrabblePoints(word))
returns:
0
Note: This function relies on scrabblePoints. Function you solved in Question 2.
Implement function declareWinner(player1Word = “skip”, player2Word = “skip”) that returns either “Player 1 Wins!”, “Player 2 Wins!”, “It’s a Tie”, “Player 1 Skipped Round”, “Player 2 Skipped Round”, “Both Players Skipped Round”. The player1Word and player2Word parameters are both type string. Assume input is always valid. This function should call on the function scrabblePoints to earn credit.
[No built-in function or method needed]
Examples:
player1Word = “PYTHON”
player2Word = “Pizza”
print(declareWinner(player1Word, player2Word))
returns:
Player 2 Wins!
print(declareWinner(player1Word))
returns:
Player 2 Skipped Round
Please do the second function only. I just needed to add the first function for reference
In: Computer Science
C++ questions about Monty Hall Problem, please make sure to divide the program into functions which perform each major task.
Imagine yourself on the set of a game show. You're given the choice of three doors. Behind one of the doors is a car you can drive home in if you guess correctly. Behind the other two doors are goats.
After you initially guess the door, the host of the game show (who knows the door holding the car) opens one of the other doors revealing a goat. He gives you the choice: stick with your original door, or choose the other unopened door.
This problem is reminiscent of a Sixties game show hosted by an individual named Monty Hall. For this assignment you will write a program simulating this game and the results of either choice. You will ask the user how many times they wish to run the simulation. If the user enters 1000 for instance, your program will run through 1000 simulations where the player sticks with the original door and 1000 simulations where the player chooses the other unopened door. After the program is completed execution, the winning percentages will then be displayed for each strategy. (Be sure to make the initial selection, Monty's selection, and the second-chance selection happen randomly.)
Be sure to divide your program into functions which perform each major task. (The purpose of this assignment is to find out whether or not it's to the player's advantage to change their selection.)
In: Computer Science