Assume the following list of keys for problems
17, 58, 80, 22, 45, 48, 95, 5, 100, 38, 36, 11, 27
Problem 4: |
(2 points) The above list is to be sorted using the quick sort algorithm as discussed in this chapter. Use pivot as the middle element of the list.
|
Problem 5: |
(2.5 points) Assume the following list of keys: 78, 40, 16, 82, 64, 67, 57, 40, 37, 47, 72, 14, 17, 27, 55 This list is to be sorted using the quick sort algorithm as discussed in this chapter. Use pivot as the median of the first, last, and middle elements of the list.
|
JAVA
In: Computer Science
You can assume that the bottles in a single order are all of the same size.
Given an order, the problem is to calculate the number of litres of lemonade required to fill all the bottles for that order.
The number of litres required for a single bottle is calculated as follows: Multiply 0.9560 with 1, 2 or 3 depending on whether the bottle size is ‘small’, ‘medium’ and ‘large’, respectively.
Part iii of this question involves writing one Python function definition.
iii.Provide a single Python function that implements the algorithm. Follow the instructions above for submitting code.
Your answer must be a translation of your algorithm from part c (ii), otherwise no marks will be awarded.
In: Computer Science
Consider two different implementations, P1 and P2, of the same instruction set. There are five classes of instructions (A, B, C, D, and E) in the instruction set. The clock rate and CPI of each class is given below.
CLK Rate |
CPI for A |
CPI for B |
CPI for C |
CPI for D |
CPI for E |
|
P1 |
2 GHz |
1 |
1 |
3 |
3 |
2 |
P2 |
3 GHz |
1 |
2 |
3 |
4 |
3 |
The total number of instructions for Program X1 are A1, B1, C1, D1 and E1 while the total number of instruction s for X2 are A2, B2, C2, D2, and E2. Compute which program runs faster on each computers P1 and P2.values are A1=230,B1=370,C1=300,D1=140,E1=95 AND A2=330,B2=250,C2=400,D2=180,E2=185
In: Computer Science
Select a research paper topic and develop an abstract.
Write 150 word topic proposal for your final project.
Your topic needs to focus on a critical challenge in cybersecurity facing National Security Professionals. This challenge can come from technology, policy, international relations, economics, or any of the fields where the digital world brings its effects to bear. Think about recent cybersecurity incidents and events. What research question comes to mind when you think of cybersecurity challenges?
Your topic proposals need to be clear and precise. Use bulleted points to clearly state the topic and address the parameters in at least one or two sentences.
In: Computer Science
I'm pretty new to JUnit testing. Can someone demonstrate how to
test one of the tree traversals and the add() and addrecursive()
methods?
public class BinaryTree {
private MorseNode<Character> root = new
MorseNode<Character>();
private MorseNode<Character> left = null;
private MorseNode<Character> right =
null;
public MorseNode<Character> getRoot() {
return root;
}
public void printPostorder(MorseNode<Character>
node) {
if(node == null) {return;}
//System.out.print(node.getLetter());
//traverse left subtree
printPostorder(node.getLeft());
//traverse right subtree
printPostorder(node.getRight());
//node
if(node.getLetter() != null) {
System.out.print(node.getLetter()
+ " ");}
}
public void printPreorder(MorseNode<Character>
node) {
if(node == null) {return;}
//System.out.print(node.getLetter());
//node
if(node.getLetter() != null) {
System.out.print(node.getLetter()
+ " ");}
//traverse left
printPreorder(node.getLeft());
//traverse right
printPreorder(node.getRight());
}
public void printInorder(MorseNode<Character>
node) {
if(node == null) {return;}
//System.out.print(node.getLetter());
//traverse left subtree
printInorder(node.getLeft());
//node
if(node.getLetter() != null) {
System.out.print(node.getLetter()
+ " ");}
//traverse right subtree
printInorder(node.getRight());
}
void printInorder() {
System.out.println("Inorder
Traversal: ");
printInorder(root);
System.out.println();
}
void printPreorder() {
System.out.println("PreOrder
Traversal: ");
printPreorder(root);
System.out.println();
}
void printPostorder() {
System.out.println("PostOrder
Traversal: ");
printPostorder(root);
System.out.println();
}
public void add(String str, char letter)
{
//System.out.println(str + "sssssss " + letter );
if (str.charAt(0) == ".".charAt(0)) {
//`System.out.println(str + letter );
root.setLeft(addRecursive(root.getLeft(),
str.substring(1), letter));
}
else if (str.charAt(0) == "-".charAt(0))
root.setRight(addRecursive(root.getRight(), str.substring(1),
letter));
}
public MorseNode<Character>
addRecursive(MorseNode<Character> current, String str,
char letter) {
if (str.length() == 0) {
return new
MorseNode<Character>(letter);
}
if ( Character.compare(str.charAt(0),
".".charAt(0)) == 0) {
current.setLeft(addRecursive(current.getLeft(),
str.substring(1), letter));
} else if
(Character.compare(str.charAt(0), "-".charAt(0)) == 0)
{
current.setRight(addRecursive(current.getRight(),
str.substring(1), letter));
}
return current;
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class BinaryTreeTest {
@Test
void testInorder() {
BinaryTree object = new BinaryTree();
char a = 'a',b='c',c='c';
String as = ".",bs = ".-",cs="..";
object.add(as, a);
object.add(bs, b);
object.add(cs, c);
String inorder = "c a b";
}
@Test
void testPostorder() {
}
@Test
void testPreorder() {
}
@Test
void testadd() {
}
}
public class MorseNode<T> {
private T letter; //letter of node
private MorseNode<T> left; //left child
private MorseNode<T> right; //right child
public MorseNode() {
}
public MorseNode(T letter) {
this.letter=letter;
}
//GETS letter in node
public T getLetter() {
return letter;
}
//SETS letter in node
public void setLetter(T letter) {
this.letter = letter;
}
//GETS left child node
public MorseNode<T> getLeft() {
return left;
}
//GETS right child node
public MorseNode<T> getRight() {
return right;
}
//SETS left child node
public void setLeft(MorseNode<T> left) {
this.left = left;
}
//SETS right child node
public void setRight(MorseNode<T> right)
{
this.right = right;
}
//print node
public String toString() {
String str = letter.toString();
return str;
}
}
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
public class MorseNodeDriver {
public static void main(String[] args) throws FileNotFoundException {
BinaryTree theTree = new BinaryTree();
File codeFile = new File("morse.txt");
Scanner myReader = new Scanner(codeFile);
while (myReader.hasNextLine() ) {
String data = myReader.nextLine();
// System.out.println(data);
int len = data.length();
//if (len==2)
theTree.add(data.substring(1), data.charAt(0));
}
theTree.printInorder();
theTree.printPostorder();
theTree.printPreorder();
//System.out.println(theTree.toString());
File translateFile = new File("translate.txt");
Scanner read = new Scanner(translateFile);
System.out.println("\n\n____________Translations__________\n");
while(read.hasNextLine()) {
String morsecode = read.nextLine();
//System.out.println(morsecode);
String[] array = morsecode.split(" ");
for(int x = 0; x< array.length; x++) {
//System.out.println(array[x]);
if(array[x].contentEquals("")) {
System.out.print(" ");
}
else if(array[x].contentEquals(".")) { //e
System.out.print(theTree.getRoot().getLeft());
}
else if(array[x].contentEquals("..")) { //i
System.out.print(theTree.getRoot().getLeft().getLeft());
}
else if(array[x].contentEquals("...")) { //s
System.out.print(theTree.getRoot().getLeft().getLeft().getLeft());
}
else if(array[x].contentEquals("....")) { //h
System.out.print(theTree.getRoot().getLeft().getLeft().getLeft().getLeft());
}
else if(array[x].contentEquals("-")) { //t
System.out.print(theTree.getRoot().getRight());
}
else if(array[x].contentEquals("--")) { //m
System.out.print(theTree.getRoot().getRight().getRight());
}
else if(array[x].contentEquals("---")) { //o
System.out.print(theTree.getRoot().getRight().getRight().getRight());
}
else if(array[x].contentEquals(".-")) { //a
System.out.print(theTree.getRoot().getLeft().getRight());
}
else if(array[x].contentEquals("..-")) { //u
System.out.print(theTree.getRoot().getLeft().getLeft().getRight());
}
else if(array[x].contentEquals("...-")) { //v
System.out.print(theTree.getRoot().getLeft().getLeft().getLeft().getRight());
}
else if(array[x].contentEquals("-.")) { //n
System.out.print(theTree.getRoot().getRight().getLeft());
}
else if(array[x].contentEquals("--.")) { //g
System.out.print(theTree.getRoot().getRight().getRight().getLeft());
}
else if(array[x].contentEquals("-.-")) { //k
System.out.print(theTree.getRoot().getRight().getLeft().getRight());
}
else if(array[x].contentEquals("-..-")) { //x
System.out.print(theTree.getRoot().getRight().getLeft().getLeft().getRight());
}
else if(array[x].contentEquals(".-.")) { //r
System.out.print(theTree.getRoot().getLeft().getRight().getLeft());
}
else if(array[x].contentEquals("-..")) { //d
System.out.print(theTree.getRoot().getRight().getLeft().getLeft());
}
else if(array[x].contentEquals("-.--")) { //y
System.out.print(theTree.getRoot().getRight().getLeft().getRight().getRight());
}
//
else if(array[x].contentEquals(".-..")) { //l
System.out.print(theTree.getRoot().getLeft().getRight().getLeft().getLeft());
}
else if(array[x].contentEquals("..-.")) { //f
System.out.print(theTree.getRoot().getLeft().getLeft().getRight().getLeft());
}
else if(array[x].contentEquals("-...")) { //b
System.out.print(theTree.getRoot().getRight().getLeft().getLeft().getLeft());
}
else if(array[x].contentEquals("-.-.")) { //c
System.out.print(theTree.getRoot().getRight().getLeft().getRight().getLeft());
}
else if(array[x].contentEquals(".---")) { //j
System.out.print(theTree.getRoot().getLeft().getRight().getRight().getRight());
}
else if(array[x].contentEquals(".--.")) { //p
System.out.print(theTree.getRoot().getLeft().getRight().getRight().getLeft());
}
else if(array[x].contentEquals("--.-")) { //q
System.out.print(theTree.getRoot().getRight().getRight().getLeft().getRight());
}
else if(array[x].contentEquals(".--")) { //w
System.out.print(theTree.getRoot().getLeft().getRight().getRight());
}
else if(array[x].contentEquals("--..")) { //z
System.out.print(theTree.getRoot().getRight().getRight().getLeft().getLeft());
}
}
System.out.println();
}
//System.out.println(theTree.getRoot().getLeft().getLeft().getLeft().getLeft());
}
}
In: Computer Science
In: Computer Science
List all the I/O techniques and describe each technique in detail with a suitable block diagram.
In: Computer Science
Choose an organization, preferably one that you work in, have worked in, or are familiar with. Throughout the semester, you will be wearing the hat of the Chief Information Security Officer (CISO) for that organization. You will be planning its Cybersecurity strategy, defining all assets that require safeguarding, and identifying all components and controls. You will propose a Cybersecurity Strategy for your organization, a plan for an effective, collaborative, organization-wide cybersecurity posture and defence.
Your Strategy should identify crosscutting principles and apply these principles across IT Strategy goals. Within those goals, the Cybersecurity Strategy should identify the main objectives, with associated major tasks and activities. The Cybersecurity Strategy should also establish the guiding principles and strategic approach needed to drive both near- and long-term priorities for your organisation cybersecurity. It should be aligned with related frameworks and strategies, including the National Institute of Standards and Technology (NIST)'s Cybersecurity Framework. Through this strategy and the associated tasks, your organisation will improve its posture and protect its systems, information, and infrastructure from the cybersecurity threat.
Task
Describe in detail the intrusion detection and prevention measures that you will deploy in your organization
1. The proposal of the appropriate positions for IDS/IPS in a network topology in order to increase the security of the environment, along with providing supportive justifications of the proposed positions.
In: Computer Science
Modify experiment 2 (below) such that the sensor value and data conversion to be shown on both LCD display and Serial Monitor
Here is modification of above program that fade LED light based upon sensed voltage level. Connect LED on pin 9 with current limiting resistor in series. Execute modified version of following program.
const int led = 9; void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); int dataConv = sensorValue*(256.0/1024); //write analog equvivalant data on led pin analogWrite(led, dataConv); // print out the value you read: Serial.println(sensorValue); Serial.println(dataConv); delay(1000); // delay in between reads for stability } |
Thanks for your help!
In: Computer Science
In Python write a loop that tests whether two lists contain the same integers in the same order:
listA = [1, 2, 3, 4]
listB = [1, 2, 3, 4]
equal = True
for ______ in ______:
if _______ != ________ :
_______ = ________
if equal:
print(_______)
else:
print(_______)
In: Computer Science
Write a heuristic computer program to solve the shortest path routing problem using the Floyd-Warshall algorithm discussed in the chapter using C++. The user should be able to input the node positions and link costs.
In: Computer Science
In C program
#include<stdio.h>
To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters & spaces, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALL HOME,which uses eight letters.
Write a program that prompts the user to enter a telephone number expressed in letters/spaces and outputs the corresponding telephone number in digits.
If the user enters more than seven letters, then process only the first seven letters.
Also output the - (hyphen) after the third digit.
Allow the user to use both uppercase and lowercase letters as well as spaces between words.
Moreover, your program should process telephone numbers until the user enters EXIT for a telephone number.
For Example:
Enter a telephone number using letterss (EXIT to quit): GET
LOAN
The corresponding telephone number is:
438-5626
Enter a telephone number using letterss (EXIT to quit): CaLl
Home
The corresponding telephone number is:
225-5466
In: Computer Science
Any java solution for this question ?
A state is divided into R*C cities.The government has launched an initiative to find the cities which are dominated by coders. Each city may or may not have coders residing in it. If the city is dominated by coders, it is marked with 1 else it is marked with 0. Two cities are termed as connected cities if they both are dominated by coders and can be reached by moving vertically, horizontally, or diagonally. Example: The given is the state with 3*3 cities and their dominance representation. City[1, 1] is directly connected to City[1, 2]. City[1, 2] is directly connected to City[1, 1], City[1, 3] and City[2, 3]. City[1, 3] is directly connected to City[1, 2] and City[2, 3]. City[2, 3] is directly connected to City[1, 2] and City[1, 3]. City[3, 1] is not connected to any of the other coder dominant cities. One or more coder dominant connected cities form the Coding belt. In a belt, there may be coder dominant cities which are not directly connected but can be reached by moving through other dominant cities. It is possible that there are multiple coding belts in the state.
Example: The given is the state with 3*3 cities and their dominance representation. For the given example, there are two coding belts. C1 represents Coding Belt 1 and C2 represents Coding Belt 2. The government wants to find the number of coder dominant cities in the largest coding belt. The government will give you the credits in the initiative. Can you help the government?
Note: For the given example, there are 4 coder dominant cities in the largest coding belt.
Input Format The first line of input consists of two space-separated integers, number of rows, R, and number of columns, C. Next R lines each consist of C space-separated integers.
Constraints 1<= R, C <=10
Output Format Print the number of coder dominant cities in the largest Coding belt.
Sample TestCase 1 Input 5 51 1 1 0 00 1 1 0 00 0 0 0 11 0 0 1 11 1 0 0 1
Output 5 Explanation There are three belts in the given 5*5 cities. Coding Belt 1 (C1): Number of Coder Dominant Cities = 5 Coding Belt 2 (C2): Number of Coder Dominant Cities = 4 Coding Belt 3 (C3): Number of Coder Dominant Cities = 3
In: Computer Science
Provided is a list of numbers. For each of the numbers in the list, determine whether they are even. If the number is even, add True to a new list called is_even. If the number is odd, then add False.
num_lst = [3, 20, -1, 9, 10]
**Please use Python**
In: Computer Science
My apologies, This is actually the question I was referring too.. It wants the pseudocode aswell as the flowchart which I am having trouble with the psedocode and what responses I have seen to the question has not made a ton of sense. Any help woudl be apprecitated. Thank you
a. Registration workers at a conference for authors of children’s books have collected data about conference participants, including the number of books each author has written and the target age of their readers. The participants have written from 1 to 40 books each, and target readers’ages range from 0 through 16. Design a program that continuously accepts the number of books written until a sentinel value is entered, and then displays a list of how many participants have written each number of books (1 through 40). b. Modify the author registration program so that a target age for each author’s audience is input until a sentinel value is entered. The output is a count of the number of books written for each of the following age groups: under 3, 3 through 7, 8 through 10, 11 through 13, and 14 and older.
In: Computer Science