In: Computer Science
What is the total delay (latency) for a frame of size 5 million bits that is being sent on a link with 10 routers each having a queuing time of 2 μs and a processing time of 1 μs. The length of the link is 2000 km, The speed of light inside the link is 2 x 108 m/s, the link has a bandwidth of 5 Mbps. Which component of the total delay is dominant? Which one is negligible? useAPA referencing style for all cited material you have used in your work. All your work must be cited.
In: Computer Science
Task 3: Implement a queue through circular linked list. Develop enqueue, dequeue, status, isempty and isfull functions. Test your code in main function with 10 elements Note: for each task, you are supposed to create three files as specified in task1, i.e., implementation file, interface file and file containing point of entry. in C++
In: Computer Science
Describe three uses of GIS (Geographic Information Systems).
In: Computer Science
(3) Implement the getNumOfNonWSCharacters() method.
getNumOfNonWSCharacters() has a string as a parameter and returns
the number of characters in the string, excluding all whitespace.
Call getNumOfNonWSCharacters() in the main() method. (4 pts)
Ex:
Enter a sample text:
We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!
You entered: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!
MENU
c - Number of non-whitespace characters
w - Number of words
f - Find text
r - Replace all !'s
s - Shorten spaces
q - Quit
Choose an option:
c
Number of non-whitespace characters: 181
Implement the getNumOfWords() method. getNumOfWords() has a string
as a parameter and returns the number of words in the string.
Hint: Words end when a space is reached except for the last
word in a sentence. Call getNumOfWords() in the main() method.
(3 pts)
Ex:
Number of words: 35
ANSWER IN JAVA more coming
In: Computer Science
Question 5
0/1 point (graded)
The following is the full path to a homework assignment file called "assignment.txt": /Users/student/Documents/projects/homeworks/assignment.txt.
Which line of code will allow you to move the assignment.txt file from the “homeworks” directory into the parent directory “projects”?
mv assignment.txt
mv assignment.txt .
mv assignment.txt ..
mv assignment.txt /projects incorrect
Answer
Incorrect:
Try again. This code does not provide enough information about where to move the file. You need to specify a relative or full path to the location where you want to move the file to.
Question 9
0/1 point (graded)
The source function reads a script from a url or file and evaluates it. Check ?source in the R console for more information.
Suppose you have an R script at ~/myproject/R/plotfig.R and getwd() shows ~/myproject/result, and you are running your R script with source('~/myproject/R/plotfig.R').
Which R function should you write in plotfig.R in order to correctly produce a plot in ~/myproject/result/fig/barplot.png?
ggsave('fig/barplot.png'), because this is the relative path to the current working directory.
ggsave('../result/fig/barplot.png'), because this is the relative path to the source file ("plotfig.R"). incorrect
ggsave('result/fig/barplot.png'), because this is the relative path to the project directory.
ggsave('barplot.png'), because this is the file name.
Question 12
1 point possible (graded)
Which of the following meanings for options following less are not correct?
(Hint: use man less to check.)
-g: Highlights current match of any searched string
-i: case-insensitive searches
-S: automatically save the search object
-X: leave file contents on screen when less exits.
Question 13
1 point possible (graded)
Which of the following statements is incorrect about preparation for a data science project?
Select ALL that apply.
Always use absolute paths when working on a data science project.
Saving .RData every time you exit R will keep your collaborator informed of what you did.
Use ggsave to save generated files for use in a presentation or a report.
Saving your code in a Word file and inserting output images is a good idea for making a reproducible report.
In: Computer Science
Question 11
1 point possible (graded)
The commands in the pipeline $ cat result.txt | grep "Harvard edX" | tee file2.txt | wc -l perform which of the following actions?
From result.txt, select lines containing “Harvard edX”, store them into file2.txt, and print all unique lines from result.txt.
From result.txt, select lines containing “Harvard edX”, and store them into file2.txt.
From result.txt, select lines containing “Harvard edX”, store them into file2.txt, and print the total number of lines which were written to file2.txt.
From result.txt, select lines containing “Harvard edX”, store them into file2.txt, and print the number of times “Harvard edX” appears.
unanswered
You have used 0 of 2 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.
Question 12
0/1 point (graded)
How is git rebase used?
To switch branches or restore working tree files incorrect
Uses a binary search to find the commit that introduced a bug
To reapply commits on top of another base tip
To reset the current HEAD to the specified state
To download objects and refs from another repository
You have used 1 of 2 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.
Question 13
1 point possible (graded)
Which of the following statements is wrong about Advanced Unix Executables, Permissions, and File Types?
In Unix, all programs are files/executables except for commands like ls, mv, and git.
which git allows a user to find the path to git.
When users create executable files themselves, they cannot be run just by typing the command - the full path must be typed instead.
ls -l can be used to inspect the permissions of each file.
In: Computer Science
In: Computer Science
1) Why should virtualization sprawl be restrained and what would you do to achieve that goal?
2) If virtualization sprawl is already an issue, what should an administrator do before it becomes even worse?
In: Computer Science
for C++ pointers:
a. Given int arr [10], *ap = &arr[2]; what is the result of (ap - arr)?
b. Given int val = 10, *x = &val, *y; y = x; *y=100; what is the output of cout << *x << *y;?
c. Given int arr [10], *ap = arr; what element does ap point to after ap +=2; ?
In: Computer Science
Please implement a HashSet using Separate Chaining to deal with collisions.
public interface SetInterface<T> {
public boolean add(T item);
public boolean remove(T item);
public boolean contains(T item);
public int size();
public boolean isEmpty();
public void clear();
public Object[] toArray();
}
public class HashSet<T> implements SetInterface<T>
{
//=============================================================================
Inner node class
private class Node<E> {
private E data;
private Node<E> next;
public Node(E data) {
this.data =
data;
this.next =
null;
}
}
//=============================================================================
Properties
private Node<T>[] buckets; // An
array of nodes
private int size;
private static final double LOAD_FACTOR = .6;
private static final int DEFAULT_SIZE = 11; // should
be prime
//=============================================================================
Constructors
public HashSet() {
buckets = (Node<T>[]) new
Node[DEFAULT_SIZE];
size = 0;
}
public HashSet(T[] items) {
//*************************************************************
TO-DO
// Make a call to your empty
constructor and then somehow fill
// this set with the items sent
in
}
//=============================================================================
Methods
@Override
public boolean add(T item) {
//*************************************************************
TO-DO
// Check to see if item is in the
set. If so return false. If not,
// check if the LOAD_FACTOR has
already been exceeded by the previous
// add and if so, call the resize()
before adding.
return true; // returns true
because we know it's been added
}
@Override
public boolean remove(T item) {
//*************************************************************
TO-DO
// To remove an item, you are
removing from a linked chain of nodes.
// Our algorithm is to copy the
data from that head node to the node to be
// removed, and then remove the
head node.
boolean success = false;
return success;
}
@Override
public boolean contains(T item) {
//*************************************************************
TO-DO
// A one-line method that
calls
// the find() method
return false;
}
@Override
public void clear() {
//*************************************************************
TO-DO
// sets all items in the array to
null
}
@Override
public int size() {
return size;
}
@Override
public boolean isEmpty() {
return size == 0;
}
@Override
public Object[] toArray() {
Object[] result = new
Object[size];
// The structure of this is
similar to the structure of toString
//*************************************************************
TO-DO
return result;
}
// Return a string that shows the array indexes,
and the items in each bucket
public String toString() {
String result = "";
String format = "[%" + ("" +
buckets.length).length() + "d] ";
// Loop through the array of
buckets. A bucket is just a chain of linked nodes.
// For each bucket, loop through
the chain, displaying the contents of the bucket
for (int i = 0; i <
buckets.length; i++) {
result +=
String.format(format, i);
// add the data
in bucket i
Node curr =
buckets[i];
while (curr !=
null) {
result += curr.data + " ";
curr = curr.next;
}
result +=
"\n";
}
return result;
}
// helper methods
// Adds all items in an array to this set.
// resize() could make use of this.
// One of the constructors can make use of this
too.
private void addAll(T[] items) {
//*************************************************************
TO-DO
// loop to add each item to the set
(calls add())
}
private void resize() {
T[] allData = (T[])
toArray(); // toArray() is method above
buckets = (Node<T>[]) new
Node[ firstPrime(2 * buckets.length) ];
size = 0;
//*************************************************************
TO-DO
// now, allData contains all the
data from the set
// and buckets points to a new
empty array
// call addAll to do the
adding
// double-check size when you are
done
}
// Very important
// Returns the node containing a particular item, or
null if not found.
// Useful for add, remove, and contains. This is a
PRIVATE helper method
private Node<T> find(T item) {
// Step 1: find the
index of where this T would be...
int index =
getHashIndex(item);
// Step 2: using the
index, check the linked nodes at that array index
// by looping through all nodes of
the bucket
Node<T> curr =
buckets[index];
while(curr != null &&
!curr.data.equals(item))
curr =
curr.next;
return curr; // we will
either be returning null (not found) or the node
// that
contains the node we are looking for
}
// Gets the index of the bucket where a given
string should go,
// by computing the hashCode, and then compressing it
to a valid index.
private int getHashIndex(T item) {
// item will always have the
hashCode() method.
// From the
int hashCode =
item.hashCode();
int index = -1; //
calculate the actual index here using the
//
hashCode and length of of the buckets array.
//*************************************************************
TO-DO
return index;
}
// Returns true if a number is prime, and false
otherwise
private static boolean isPrime(int n) {
if (n <= 1) return
false;
if (n == 2) return
true;
for (int i = 2; i * i <= n;
i++)
if (n % i ==
0) return false;
return true;
}
// Returns the first prime >= n
private static int firstPrime(int n) {
while (!isPrime(n)) n++;
return n;
}
}
public class Tester {
public static void main(String[] args) {
HashSet<String> set = new
HashSet<>();
System.out.println("true? " +
set.isEmpty());
System.out.println("true? " +
set.add("cat"));
System.out.println("true? " +
set.add("dog"));
System.out.println("false? " +
set.add("dog"));
System.out.println("2? " +
set.size());
System.out.println("false? " +
set.isEmpty());
System.out.println(set.toString());
for(char c :
"ABCDEFGHIJKLMNOPQUSTUVWXYZ".toCharArray())
set.add("" +
c);
System.out.println(set.toString());
}
}
In: Computer Science
Make sure you are using the appropriate indentation and styling conventions
Open the online API documentation for the ArrayList class, or the Rephactor Lists topic (or both). You may want to refer to these as you move forward.
Exercise 1 (15 Points)
Exercise 2 (15 Points)
Chris, Robert, Scarlett, Clark, Jeremy, Gwyneth, Mark
Exercise 3 (15 Points)
Current size of avengers: xxx
Exercise 4 (15 Points)
Now the size is: xxx
Exercise 5 (20 Points)
Exercise 6 (20 Points)
In: Computer Science
Find a company or organization which provide cloud computing and services, analyze the information by listing and commenting their:
a. Services to provide
b. Major clients
c. Benefits
d. Issues and problems
In: Computer Science
I have a set of 100,000 random integers. How long does it take to determine the maximum value within the first 25,000, 50,000 and 100,000 integers? Will processing 100,000 integers take 4 times longer than processing 25,000? You may use any programming language/technique. It is possible the time will be very small, so you might need to repeat the experiment N times and determine an average value for time. Complete this table. Source code is not needed.
|
Number |
Time |
|
25,000 |
|
|
50,000 |
|
|
100,000 |
|
|
Language/Tool used: |
|
|
Technique used: |
In: Computer Science